// $Id$
//
// SuperTux - A Jump'n Run
-// Copyright (C) 2004 Matthias Braun <matze@braunis.de
+// Copyright (C) 2006 Matthias Braun <matze@braunis.de>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
#include "script_manager.hpp"
#include "scripting/wrapper_util.hpp"
#include "script_interface.hpp"
-#include "msg.hpp"
+#include "log.hpp"
Sector* Sector::_current = 0;
+bool Sector::show_collrects = false;
+bool Sector::draw_solids_only = false;
+
Sector::Sector()
: currentmusic(LEVEL_MUSIC), gravity(10),
player(0), solids(0), camera(0)
try {
return create_object(name, reader);
} catch(std::exception& e) {
- msg_warning << e.what() << "" << std::endl;
+ log_warning << e.what() << "" << std::endl;
}
return 0;
fix_old_tiles();
if(!camera) {
- msg_warning << "sector '" << name << "' does not contain a camera." << std::endl;
+ log_warning << "sector '" << name << "' does not contain a camera." << std::endl;
update_game_objects();
add_object(new Camera(this));
}
spawnpoints.push_back(sp);
}
} else {
- msg_warning << "Unknown token '" << iter.item() << "' in reset-points." << std::endl;
+ log_warning << "Unknown token '" << iter.item() << "' in reset-points." << std::endl;
}
}
}
if(object) {
add_object(object);
} else {
- msg_warning << "Unknown object '" << iter.item() << "' in level." << std::endl;
+ log_warning << "Unknown object '" << iter.item() << "' in level." << std::endl;
}
}
}
}
}
if(!sp) {
- msg_warning << "Spawnpoint '" << spawnpoint << "' not found." << std::endl;
+ log_warning << "Spawnpoint '" << spawnpoint << "' not found." << std::endl;
if(spawnpoint != "main") {
activate("main");
} else {
player->move(player_pos);
camera->reset(player->get_pos());
+ update_game_objects();
// Run init script
if(init_script != "") {
if(solids == 0) {
solids = tilemap;
} else {
- msg_warning << "Another solid tilemaps added. Ignoring" << std::endl;
+ log_warning << "Another solid tilemaps added. Ignoring" << std::endl;
}
}
Camera* camera = dynamic_cast<Camera*> (object);
if(camera) {
if(this->camera != 0) {
- msg_warning << "Multiple cameras added. Ignoring" << std::endl;
+ log_warning << "Multiple cameras added. Ignoring" << std::endl;
return false;
}
this->camera = camera;
Player* player = dynamic_cast<Player*> (object);
if(player) {
if(this->player != 0) {
- msg_warning << "Multiple players added. Ignoring" << std::endl;
+ log_warning << "Multiple players added. Ignoring" << std::endl;
return false;
}
this->player = player;
ScriptInterface* interface = dynamic_cast<ScriptInterface*> (object);
if(interface != NULL) {
HSQUIRRELVM vm = script_manager->get_vm();
+ int oldtop = sq_gettop(vm);
sq_pushobject(vm, sector_table);
- interface->unexpose(vm, -1);
- sq_pop(vm, 1);
+ try {
+ interface->unexpose(vm, -1);
+ } catch(std::exception& e) {
+ log_warning << "Couldn't unregister object: " << e.what() << std::endl;
+ }
+ sq_settop(vm, oldtop);
}
}
GameObject* object = *i;
if(!object->is_valid())
continue;
-
+
+ if (draw_solids_only)
+ {
+ TileMap* tm = dynamic_cast<TileMap*>(object);
+ if (tm && !tm->is_solid())
+ continue;
+ }
+
object->draw(context);
}
+ if(show_collrects) {
+ Color col(0.2, 0.2, 0.2, 0.7);
+ for(MovingObjects::iterator i = moving_objects.begin();
+ i != moving_objects.end(); ++i) {
+ MovingObject* object = *i;
+ const Rect& rect = object->get_bbox();
+
+ context.draw_filled_rect(rect, col, LAYER_FOREGROUND1 + 10);
+ }
+ }
+
context.pop_transform();
}
case HERRING_MUSIC:
sound_manager->play_music("music/salcon.ogg");
break;
+ case HERRING_WARNING_MUSIC:
+ sound_manager->stop_music(TUX_INVINCIBLE_TIME_WARNING);
+ break;
default:
sound_manager->play_music("");
break;