Added ticking sound (self-made, public domain) for Bomb
authorChristoph Sommer <mail@christoph-sommer.de>
Thu, 22 Jun 2006 14:50:56 +0000 (14:50 +0000)
committerChristoph Sommer <mail@christoph-sommer.de>
Thu, 22 Jun 2006 14:50:56 +0000 (14:50 +0000)
SVN-Revision: 3694

data/sounds/ticking.wav [new file with mode: 0644]
src/badguy/bomb.cpp
src/badguy/bomb.hpp

diff --git a/data/sounds/ticking.wav b/data/sounds/ticking.wav
new file mode 100644 (file)
index 0000000..3dbf6ea
Binary files /dev/null and b/data/sounds/ticking.wav differ
index 17ae155..e765869 100644 (file)
@@ -32,6 +32,26 @@ Bomb::Bomb(const Vector& pos, Direction dir)
   this->dir = dir;
   sprite->set_action(dir == LEFT ? "ticking-left" : "ticking-right");
   countMe = false;
+
+  ticking.reset(sound_manager->create_sound_source("sounds/ticking.wav"));
+  ticking->set_position(get_pos());
+  ticking->set_looping(true);
+  ticking->set_gain(2.0);
+  ticking->set_reference_distance(32);
+  ticking->play();
+}
+
+Bomb::Bomb(const Bomb& other)
+       : BadGuy(other), state(other.state), timer(other.timer)
+{
+  if (state == STATE_TICKING) {
+    ticking.reset(sound_manager->create_sound_source("sounds/ticking.wav"));
+    ticking->set_position(get_pos());
+    ticking->set_looping(true);
+    ticking->set_gain(2.0);
+    ticking->set_reference_distance(32);
+    ticking->play();
+  }
 }
 
 void
@@ -71,6 +91,7 @@ Bomb::active_update(float )
 {
   switch(state) {
     case STATE_TICKING:
+      ticking->set_position(get_pos());
       if(timer.check()) {
         explode();
       }
@@ -86,6 +107,7 @@ Bomb::active_update(float )
 void
 Bomb::explode()
 {
+  ticking->stop();
   state = STATE_EXPLODING;
   set_group(COLGROUP_TOUCHABLE);
   sprite->set_action("explosion");
index abd8b9d..0bbe1c4 100644 (file)
@@ -26,6 +26,7 @@ class Bomb : public BadGuy
 {
 public:
   Bomb(const Vector& pos, Direction dir);
+  Bomb(const Bomb& bomb);
 
   void write(lisp::Writer& writer);
   HitResponse collision_solid(GameObject& other, const CollisionHit& hit);
@@ -45,6 +46,9 @@ private:
   
   State state;
   Timer timer;
+
+  std::auto_ptr<SoundSource> ticking;
+
 };
 
 #endif