Add current level to another debug message
[supertux.git] / src / badguy / kamikazesnowball.cpp
index daadd93..49ae582 100644 (file)
 #include "sprite/sprite.hpp"
 #include "supertux/object_factory.hpp"
 
-/* 
+/*
  * Kamikaze Snowball will fly in one direction until he hits something.
- * On impact he is destroyed, trying to kill what he hit or hit him. 
+ * 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";
 }
 
 KamikazeSnowball::KamikazeSnowball(const Reader& reader) :
   BadGuy(reader, "images/creatures/snowball/kamikaze-snowball.sprite")
 {
-  sound_manager->preload(SPLAT_SOUND);
+  SoundManager::current()->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);
+  SoundManager::current()->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");
 }
@@ -62,7 +64,8 @@ KamikazeSnowball::collision_solid(const CollisionHit& hit)
 {
   if(hit.top || hit.bottom) {
     physic.set_velocity_y(0);
-  } else if(hit.left || hit.right) {
+  }
+  if(hit.left || hit.right) {
     kill_collision();
   }
 }
@@ -71,7 +74,7 @@ void
 KamikazeSnowball::kill_collision()
 {
   sprite->set_action(dir == LEFT ? "collision-left" : "collision-right");
-  sound_manager->play(SPLAT_SOUND, get_pos());
+  SoundManager::current()->play(SPLAT_SOUND, get_pos());
   physic.set_velocity_x(0);
   physic.set_velocity_y(0);
   physic.enable_gravity(true);