Added explode(). Avoid duplicated code, futhermore, allows any badguy to explode.
authorRicardo Cruz <rick2@aeiou.pt>
Sat, 8 May 2004 23:46:43 +0000 (23:46 +0000)
committerRicardo Cruz <rick2@aeiou.pt>
Sat, 8 May 2004 23:46:43 +0000 (23:46 +0000)
SVN-Revision: 1048

src/badguy.cpp
src/badguy.h

index f852730..e02da38 100644 (file)
@@ -929,6 +929,12 @@ BadGuy::kill_me(int score)
   play_sound(sounds[SND_FALL], SOUND_CENTER_SPEAKER);
 }
 
+void BadGuy::explode(BadGuy *badguy)
+{
+World::current()->add_bad_guy(badguy->base.x, badguy->base.y, BAD_BOMB);
+badguy->remove_me();
+}
+
 void
 BadGuy::collision(void *p_c_object, int c_object, CollisionType type)
 {
@@ -974,9 +980,7 @@ BadGuy::collision(void *p_c_object, int c_object, CollisionType type)
         if (pbad_c->kind == BAD_MRBOMB)
         {
           // mrbomb transforms into a bomb now
-          World::current()->add_bad_guy(pbad_c->base.x, pbad_c->base.y,
-                                        BAD_BOMB);
-          pbad_c->remove_me();
+          explode(pbad_c);
           return;
         }
         else if (pbad_c->kind != BAD_MRBOMB)
@@ -991,9 +995,7 @@ BadGuy::collision(void *p_c_object, int c_object, CollisionType type)
         if (pbad_c->kind == BAD_MRBOMB)
         {
           // mrbomb transforms into a bomb now
-          World::current()->add_bad_guy(pbad_c->base.x, pbad_c->base.y,
-                                        BAD_BOMB);
-          pbad_c->remove_me();
+          explode(pbad_c);
           return;
         }
         else
@@ -1074,6 +1076,7 @@ BadGuy::collision(void *p_c_object, int c_object, CollisionType type)
     }
 }
 
+
 //---------------------------------------------------------------------------
 
 void load_badguy_gfx()
index 33b7ac0..caaa8e9 100644 (file)
@@ -111,6 +111,8 @@ public:
   void draw();
   std::string type() { return "BadGuy"; };
 
+  void explode(BadGuy* badguy);
+
   void collision(void* p_c_object, int c_object,
                  CollisionType type = COLLISION_NORMAL);