Started some work on the yeti boss
[supertux.git] / src / badguy / bomb.cpp
index c7445a2..e6dd34d 100644 (file)
@@ -44,7 +44,8 @@ Bomb::collision_player(Player& player, const CollisionHit& )
 HitResponse
 Bomb::collision_badguy(BadGuy& badguy, const CollisionHit& )
 {
-  badguy.kill_fall();
+  if(state == 1)
+    badguy.kill_fall();
   return ABORT_MOVE;
 }
 
@@ -54,9 +55,7 @@ Bomb::active_action(float )
   switch(state) {
     case 0:
       if(timer.check()) {
-        state = 1;
-        sprite->set_action("explosion");
-        timer.start(EXPLOSIONTIME);
+        explode();
       }
       break;
     case 1:
@@ -68,6 +67,18 @@ Bomb::active_action(float )
 }
 
 void
+Bomb::explode()
+{
+  state = 1;
+  sprite->set_action("explosion");
+  SoundManager::get()->play_sound(IDToSound(SND_EXPLODE), get_pos(),
+      Sector::current()->player->get_pos());
+  timer.start(EXPLOSIONTIME);
+}
+
+void
 Bomb::kill_fall()
 {
+  explode();
 }
+