Changed Yeti behaviour. You must stun him (jump on him) when is under a falling stala...
[supertux.git] / src / badguy / bomb.cpp
index 88ed94e..e6dd34d 100644 (file)
@@ -9,7 +9,7 @@ Bomb::Bomb(const Vector& pos, Direction dir)
 {
   start_position = pos;
   bbox.set_pos(pos);
-  bbox.set_size(32, 32);
+  bbox.set_size(31.8, 31.8);
   sprite = sprite_manager->create("bomb");
   state = 0;
   timer.start(TICKINGTIME);
@@ -18,13 +18,13 @@ Bomb::Bomb(const Vector& pos, Direction dir)
 }
 
 void
-Bomb::write(LispWriter& writer)
+Bomb::write(lisp::Writer& )
 {
   // bombs are only temporarily so don't write them out...
 }
 
 HitResponse
-Bomb::collision_solid(GameObject& other, const CollisionHit& hit)
+Bomb::collision_solid(GameObject& , const CollisionHit& hit)
 {
   if(fabsf(hit.normal.y) > .5)
     physic.set_velocity_y(0);
@@ -33,7 +33,7 @@ Bomb::collision_solid(GameObject& other, const CollisionHit& hit)
 }
 
 HitResponse
-Bomb::collision_player(Player& player, const CollisionHit& hit)
+Bomb::collision_player(Player& player, const CollisionHit& )
 {
   if(state == 1) {
     player.kill(Player::SHRINK);
@@ -41,15 +41,21 @@ Bomb::collision_player(Player& player, const CollisionHit& hit)
   return ABORT_MOVE;
 }
 
+HitResponse
+Bomb::collision_badguy(BadGuy& badguy, const CollisionHit& )
+{
+  if(state == 1)
+    badguy.kill_fall();
+  return ABORT_MOVE;
+}
+
 void
-Bomb::active_action(float elapsed_time)
+Bomb::active_action(float )
 {
   switch(state) {
     case 0:
       if(timer.check()) {
-        state = 1;
-        sprite->set_action("explosion");
-        timer.start(EXPLOSIONTIME);
+        explode();
       }
       break;
     case 1:
@@ -61,6 +67,18 @@ Bomb::active_action(float elapsed_time)
 }
 
 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();
 }
+