From: Ricardo Cruz Date: Sat, 8 May 2004 23:46:43 +0000 (+0000) Subject: Added explode(). Avoid duplicated code, futhermore, allows any badguy to explode. X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=a7c1a896e8322ac1d133516e218a346db6d2b09f;p=supertux.git Added explode(). Avoid duplicated code, futhermore, allows any badguy to explode. SVN-Revision: 1048 --- diff --git a/src/badguy.cpp b/src/badguy.cpp index f852730e1..e02da3818 100644 --- a/src/badguy.cpp +++ b/src/badguy.cpp @@ -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() diff --git a/src/badguy.h b/src/badguy.h index 33b7ac03b..caaa8e99c 100644 --- a/src/badguy.h +++ b/src/badguy.h @@ -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);