Removed a global variable
[supertux.git] / src / sector.cpp
index c0492f7..0d8bcc1 100644 (file)
 Sector* Sector::_current = 0;
 
 bool Sector::show_collrects = false;
+bool Sector::draw_solids_only = false;
 
-Sector::Sector()
-  : currentmusic(LEVEL_MUSIC), gravity(10),
+Sector::Sector(Level* parent)
+  : level(parent), currentmusic(LEVEL_MUSIC), gravity(10),
     player(0), solids(0), camera(0)
 {
   add_object(new Player(player_status));
@@ -119,6 +120,12 @@ Sector::~Sector()
     delete *i;
 }
 
+Level*
+Sector::get_level()
+{
+  return level;
+}
+
 GameObject*
 Sector::parse_object(const std::string& name, const lisp::Lisp& reader)
 {
@@ -700,7 +707,14 @@ Sector::draw(DrawingContext& context)
     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);
   }
 
@@ -1079,16 +1093,14 @@ bool
 Sector::add_bullet(const Vector& pos, float xm, Direction dir)
 {
   // TODO remove this function and move these checks elsewhere...
-  static const size_t MAX_FIRE_BULLETS = 2;
-  static const size_t MAX_ICE_BULLETS = 1;
 
   Bullet* new_bullet = 0;
   if(player_status->bonus == FIRE_BONUS) {
-    if(bullets.size() > MAX_FIRE_BULLETS-1)
+    if((int)bullets.size() >= player_status->max_fire_bullets)
       return false;
     new_bullet = new Bullet(pos, xm, dir, FIRE_BULLET);
   } else if(player_status->bonus == ICE_BONUS) {
-    if(bullets.size() > MAX_ICE_BULLETS-1)
+    if((int)bullets.size() >= player_status->max_ice_bullets)
       return false;
     new_bullet = new Bullet(pos, xm, dir, ICE_BULLET);
   } else {
@@ -1159,7 +1171,7 @@ Sector::inside(const Rect& rect) const
 {
   if(rect.p1.x > solids->get_width() * 32 
       || rect.p1.y > solids->get_height() * 32
-      || rect.p2.x < 0 || rect.p2.y < 0)
+      || rect.p2.x < 0)
     return false;
 
   return true;