Added a "gotoend" cheat to put Tux near the end of the level.
[supertux.git] / src / sector.cpp
index 9064af7..c0c86f3 100644 (file)
@@ -40,6 +40,7 @@
 #include "resources.h"
 #include "interactive_object.h"
 #include "door.h"
+#include "statistics.h"
 
 Sector* Sector::_current = 0;
 
@@ -466,7 +467,13 @@ Sector::update_game_objects()
             std::remove(smoke_clouds.begin(), smoke_clouds.end(), smoke_cloud),
             smoke_clouds.end());
       }
-                                                                                
+      Particles* particle = dynamic_cast<Particles*> (*i);
+      if(particle) {
+        particles.erase(
+            std::remove(particles.begin(), particles.end(), particle),
+            particles.end());
+      }
+
       delete *i;
       i = gameobjects.erase(i);
     } else {
@@ -500,7 +507,9 @@ Sector::update_game_objects()
           SmokeCloud* smoke_cloud = dynamic_cast<SmokeCloud*> (*i);
           if(smoke_cloud)
             smoke_clouds.push_back(smoke_cloud);
-
+          Particles* particle = dynamic_cast<Particles*> (*i);
+          if(particle)
+            particles.push_back(particle);
 
           gameobjects.push_back(*i);
   }
@@ -645,7 +654,7 @@ Sector::collision_handler()
 void
 Sector::add_score(const Vector& pos, int s)
 {
-  player_status.score += s;
+  global_stats.add_points(SCORE_STAT, s);
                                                                                 
   add_object(new FloatingScore(pos, s));
 }
@@ -715,7 +724,8 @@ Sector::add_bullet(const Vector& pos, float xm, Direction dir)
   else
     throw std::runtime_error("wrong bullet type.");
   add_object(new_bullet);
-                                                                                
+
+  global_stats.add_points(SHOTS_STAT, 1);
   SoundManager::get()->play_sound(IDToSound(SND_SHOOT));
                                                                                 
   return true;
@@ -728,6 +738,13 @@ Sector::add_smoke_cloud(const Vector& pos)
   return true;
 }
 
+bool
+Sector::add_particles(const Vector& epicenter, const Vector& velocity, const Vector& acceleration, int number, Color color, int size, int life_time)
+{
+  add_object(new Particles(epicenter, velocity, acceleration, number, color, size, life_time));
+  return true;
+}
+
 /* Break a brick: */
 bool
 Sector::trybreakbrick(const Vector& pos, bool small)
@@ -764,9 +781,9 @@ Sector::trybreakbrick(const Vector& pos, bool small)
               counting_distros = false;
               solids->change_at(pos, tile->next_tile);
             }
-                                                                                
+
           SoundManager::get()->play_sound(IDToSound(SND_DISTRO));
-          player_status.score = player_status.score + SCORE_DISTRO;
+          global_stats.add_points(SCORE_STAT, SCORE_DISTRO);
           player_status.distros++;
           return true;
         }
@@ -782,7 +799,7 @@ Sector::trybreakbrick(const Vector& pos, bool small)
                                                                                 
           /* Get some score: */
           SoundManager::get()->play_sound(IDToSound(SND_BRICK));
-          player_status.score = player_status.score + SCORE_BRICK;
+          global_stats.add_points(SCORE_STAT, SCORE_BRICK);
                                                                                 
           return true;
         }
@@ -820,7 +837,7 @@ Sector::tryemptybox(const Vector& pos, Direction col_side)
     case 1: // Box with a distro!
       add_bouncy_distro(Vector(posx, posy));
       SoundManager::get()->play_sound(IDToSound(SND_DISTRO));
-      player_status.score = player_status.score + SCORE_DISTRO;
+      global_stats.add_points(SCORE_STAT, SCORE_DISTRO);
       player_status.distros++;
       break;
                                                                                 
@@ -885,7 +902,7 @@ Sector::trygrabdistro(const Vector& pos, int bounciness)
                               (int)(pos.y / 32) * 32));
     }
                                                                             
-  player_status.score = player_status.score + SCORE_DISTRO;
+  global_stats.add_points(SCORE_STAT, SCORE_DISTRO);
   player_status.distros++;
 
 }