MatzeB: that shoudl fix the cases where you die when picking up an iceflower
authorIngo Ruhnke <grumbel@gmx.de>
Wed, 28 Apr 2004 20:24:34 +0000 (20:24 +0000)
committerIngo Ruhnke <grumbel@gmx.de>
Wed, 28 Apr 2004 20:24:34 +0000 (20:24 +0000)
SVN-Revision: 817

src/gameobjs.cpp
src/special.cpp
src/world.cpp
src/world.h

index 5133535..aaf6319 100644 (file)
@@ -40,7 +40,14 @@ BouncyDistro::action(double frame_ratio)
   base.ym += 0.1 * frame_ratio;
 
   if (base.ym >= 0)
-    World::current()->bouncy_distros.erase(static_cast<std::vector<BouncyDistro>::iterator>(this));
+    {
+      std::vector<BouncyDistro*>::iterator i
+        = std::find(World::current()->bouncy_distros.begin(), 
+                    World::current()->bouncy_distros.end(), 
+                    this);
+      if (i != World::current()->bouncy_distros.end())
+        World::current()->bouncy_distros.erase(i);
+    }
 }
 
 void
@@ -71,7 +78,9 @@ BrokenBrick::action(double frame_ratio)
   base.y = base.y + base.ym * frame_ratio;
 
   if (!timer.check())
-    World::current()->broken_bricks.erase(static_cast<std::vector<BrokenBrick>::iterator>(this));
+    {
+      World::current()->broken_bricks.erase(static_cast<std::vector<BrokenBrick>::iterator>(this));
+    }
 }
 
 void
index b287476..b1136c7 100644 (file)
@@ -350,12 +350,6 @@ Upgrade::collision(void* p_c_object, int c_object, CollisionType type)
               pplayer->base.height = 64;
               pplayer->base.y -= 32;
             }
-         if(collision_object_map(pplayer->base))
-            {
-              pplayer->base.height = 32;
-              pplayer->base.y += 32;
-              pplayer->duck = true;
-            }
         }
       else if (kind == UPGRADE_HERRING)
         {
index fb9d49b..7ec7eac 100644 (file)
@@ -198,7 +198,7 @@ World::draw()
 
   /* (Bouncy bricks): */
   for (unsigned int i = 0; i < bouncy_bricks.size(); ++i)
-    bouncy_bricks[i].draw();
+    bouncy_bricks[i]->draw();
 
   for (BadGuys::iterator i = bad_guys.begin(); i != bad_guys.end(); ++i)
     (*i)->draw();
@@ -209,16 +209,16 @@ World::draw()
     bullets[i].draw();
 
   for (unsigned int i = 0; i < floating_scores.size(); ++i)
-    floating_scores[i].draw();
+    floating_scores[i]->draw();
 
   for (unsigned int i = 0; i < upgrades.size(); ++i)
     upgrades[i].draw();
 
   for (unsigned int i = 0; i < bouncy_distros.size(); ++i)
-    bouncy_distros[i].draw();
+    bouncy_distros[i]->draw();
 
   for (unsigned int i = 0; i < broken_bricks.size(); ++i)
-    broken_bricks[i].draw();
+    broken_bricks[i]->draw();
 
   /* Draw foreground: */
   for (y = 0; y < 15; ++y)
@@ -244,11 +244,11 @@ World::action(double frame_ratio)
 
   /* Handle bouncy distros: */
   for (unsigned int i = 0; i < bouncy_distros.size(); i++)
-    bouncy_distros[i].action(frame_ratio);
+    bouncy_distros[i]->action(frame_ratio);
 
   /* Handle broken bricks: */
   for (unsigned int i = 0; i < broken_bricks.size(); i++)
-    broken_bricks[i].action(frame_ratio);
+    broken_bricks[i]->action(frame_ratio);
 
   /* Handle distro counting: */
   if (counting_distros)
@@ -261,10 +261,10 @@ World::action(double frame_ratio)
 
   // Handle all kinds of game objects
   for (unsigned int i = 0; i < bouncy_bricks.size(); i++)
-    bouncy_bricks[i].action(frame_ratio);
+    bouncy_bricks[i]->action(frame_ratio);
   
   for (unsigned int i = 0; i < floating_scores.size(); i++)
-    floating_scores[i].action(frame_ratio);
+    floating_scores[i]->action(frame_ratio);
 
   for (unsigned int i = 0; i < bullets.size(); ++i)
     bullets[i].action(frame_ratio);
@@ -387,16 +387,16 @@ World::add_score(float x, float y, int s)
 {
   player_status.score += s;
 
-  FloatingScore new_floating_score;
-  new_floating_score.init(x,y,s);
+  FloatingScore* new_floating_score = new FloatingScore();
+  new_floating_score->init(x,y,s);
   floating_scores.push_back(new_floating_score);
 }
 
 void
 World::add_bouncy_distro(float x, float y)
 {
-  BouncyDistro new_bouncy_distro;
-  new_bouncy_distro.init(x,y);
+  BouncyDistro* new_bouncy_distro = new BouncyDistro();
+  new_bouncy_distro->init(x,y);
   bouncy_distros.push_back(new_bouncy_distro);
 }
 
@@ -413,16 +413,16 @@ World::add_broken_brick(Tile* tile, float x, float y)
 void
 World::add_broken_brick_piece(Tile* tile, float x, float y, float xm, float ym)
 {
-  BrokenBrick new_broken_brick;
-  new_broken_brick.init(tile, x, y, xm, ym);
+  BrokenBrick* new_broken_brick = new BrokenBrick();
+  new_broken_brick->init(tile, x, y, xm, ym);
   broken_bricks.push_back(new_broken_brick);
 }
 
 void
 World::add_bouncy_brick(float x, float y)
 {
-  BouncyBrick new_bouncy_brick;
-  new_bouncy_brick.init(x,y);
+  BouncyBrick* new_bouncy_brick = new BouncyBrick();
+  new_bouncy_brick->init(x,y);
   bouncy_bricks.push_back(new_bouncy_brick);
 }
 
index 62ca1d6..591d305 100644 (file)
@@ -50,10 +50,10 @@ private:
 
   static World* current_;
 public:
-  std::vector<BouncyDistro> bouncy_distros;
-  std::vector<BrokenBrick>  broken_bricks;
-  std::vector<BouncyBrick>  bouncy_bricks;
-  std::vector<FloatingScore> floating_scores;
+  std::vector<BouncyDistro*> bouncy_distros;
+  std::vector<BrokenBrick*>  broken_bricks;
+  std::vector<BouncyBrick*>  bouncy_bricks;
+  std::vector<FloatingScore*> floating_scores;
 
   std::vector<Upgrade> upgrades;
   std::vector<Bullet> bullets;