Rename the "BombFish" class to "SkyDive". The factory now uses the string "skydive".
[supertux.git] / src / badguy / kamikazesnowball.cpp
index 46ea369..9f67c6b 100644 (file)
@@ -25,7 +25,7 @@
  * On impact he is destroyed, trying to kill what he hit or hit him. 
  */
 namespace{
-  static const float SPEED = 200;
+  static const float KAMIKAZE_SPEED = 200;
   const std::string SPLAT_SOUND = "sounds/splat.wav";
 }
 
@@ -33,18 +33,20 @@ KamikazeSnowball::KamikazeSnowball(const Reader& reader) :
   BadGuy(reader, "images/creatures/snowball/kamikaze-snowball.sprite")
 {
   sound_manager->preload(SPLAT_SOUND);
+  set_action (dir == LEFT ? "left" : "right", /* loops = */ -1);
 }
 
 KamikazeSnowball::KamikazeSnowball(const Vector& pos, Direction d)
   : BadGuy(pos, d, "images/creatures/snowball/kamikaze-snowball.sprite")
 {
   sound_manager->preload(SPLAT_SOUND);
+  set_action (dir == LEFT ? "left" : "right", /* loops = */ -1);
 }
 
 void
 KamikazeSnowball::initialize()
 {
-  physic.set_velocity_x(dir == LEFT ? -SPEED : SPEED);
+  physic.set_velocity_x(dir == LEFT ? -KAMIKAZE_SPEED : KAMIKAZE_SPEED);
   physic.enable_gravity(false);
   sprite->set_action(dir == LEFT ? "left" : "right");
 }
@@ -83,14 +85,13 @@ KamikazeSnowball::kill_collision()
 HitResponse
 KamikazeSnowball::collision_player(Player& player, const CollisionHit& hit)
 {
+  //Hack to tell if we should die
   HitResponse response = BadGuy::collision_player(player, hit);
-  if(response == FORCE_MOVE){
+  if(response == FORCE_MOVE) {
     kill_collision();
-    response = ABORT_MOVE;
   }
-  return response;
-}
 
-IMPLEMENT_FACTORY(KamikazeSnowball, "kamikazesnowball");
+  return ABORT_MOVE;
+}
 
 /* EOF */