static const float X_OFFSCREEN_DISTANCE = 1280;
static const float Y_OFFSCREEN_DISTANCE = 800;
-static const int LAYER_FALLING = 500;
BadGuy::BadGuy(const Vector& pos, const std::string& sprite_name_, int layer_) :
MovingSprite(pos, sprite_name_, layer_, COLGROUP_DISABLED),
physic.set_acceleration_y(0);
physic.enable_gravity(true);
set_state(STATE_FALLING);
- layer = LAYER_FALLING;
+
+ // Set the badguy layer to be the foremost, so that
+ // this does not reveal secret tilemaps:
+ layer = Sector::current()->get_foremost_layer() + 1;
// start dead-script
run_dead_script();
throw scripting::SquirrelError(global_vm, "Couldn't get sector table");
sq_addref(global_vm, §or_table);
sq_pop(global_vm, 1);
+
+ foremost_layer = calculate_foremost_layer();
}
Sector::~Sector()
camera->get_translation() + Vector(1600, 1200) + Vector(SCREEN_WIDTH,SCREEN_HEIGHT));
}
+int
+Sector::calculate_foremost_layer()
+{
+ int layer = 0;
+ for(auto i = gameobjects.begin(); i != gameobjects.end(); ++i)
+ {
+ TileMap* tm = dynamic_cast<TileMap*>(i->get());
+ if (!tm) continue;
+ if(tm->get_layer() > foremost_layer)
+ {
+ foremost_layer = tm->get_layer();
+ }
+ }
+ return layer;
+}
+
+int
+Sector::get_foremost_layer()
+{
+ return foremost_layer;
+}
+
void
Sector::update(float elapsed_time)
{
Rectf get_active_region();
+ int get_foremost_layer();
+
/**
* returns the width (in px) of a sector)
*/
void fix_old_tiles();
+ int calculate_foremost_layer();
+
private:
static Sector* _current;
Color ambient_light;
+ int foremost_layer;
+
public: // TODO make this private again
/// show collision rectangles of moving objects (for debugging)
static bool show_collrects;