From: Christoph Sommer Date: Thu, 22 Jun 2006 14:50:56 +0000 (+0000) Subject: Added ticking sound (self-made, public domain) for Bomb X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=ed857c9b9d79e963b1443e30cfed9fa0bcdb1cc2;p=supertux.git Added ticking sound (self-made, public domain) for Bomb SVN-Revision: 3694 --- diff --git a/data/sounds/ticking.wav b/data/sounds/ticking.wav new file mode 100644 index 000000000..3dbf6ea66 Binary files /dev/null and b/data/sounds/ticking.wav differ diff --git a/src/badguy/bomb.cpp b/src/badguy/bomb.cpp index 17ae15565..e765869d8 100644 --- a/src/badguy/bomb.cpp +++ b/src/badguy/bomb.cpp @@ -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"); diff --git a/src/badguy/bomb.hpp b/src/badguy/bomb.hpp index abd8b9d06..0bbe1c4f9 100644 --- a/src/badguy/bomb.hpp +++ b/src/badguy/bomb.hpp @@ -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 ticking; + }; #endif