From: Marek Moeckel Date: Mon, 23 May 2005 14:32:32 +0000 (+0000) Subject: made the phone ringing again X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=ee3bec916bb8341fbc1db000beb77b8320cdf852;p=supertux.git made the phone ringing again SVN-Revision: 2539 --- diff --git a/src/object/ambient_sound.cpp b/src/object/ambient_sound.cpp index 7456c80cf..ad5b896f8 100644 --- a/src/object/ambient_sound.cpp +++ b/src/object/ambient_sound.cpp @@ -76,6 +76,31 @@ AmbientSound::AmbientSound(const lisp::Lisp& lisp) latency=0; } +AmbientSound::AmbientSound(Vector pos, float factor, float bias, float vol, std::string file) +{ + + position.x=pos.x; + position.y=pos.y; + + dimension.x=0; + dimension.y=0; + + distance_factor=factor*factor; + distance_bias=bias*bias; + maximumvolume=vol; + sample=file; + + // set default silence_distance + + if (distance_factor == 0) + silence_distance = 10e99; + else + silence_distance = 1/distance_factor; + + playing=-1; // not playing at the beginning + latency=0; +} + AmbientSound::~AmbientSound() { stop_playing(); } diff --git a/src/object/ambient_sound.h b/src/object/ambient_sound.h index 864bf4a7e..ce39f7a6b 100644 --- a/src/object/ambient_sound.h +++ b/src/object/ambient_sound.h @@ -52,6 +52,7 @@ class AmbientSound : public GameObject { public: AmbientSound(const lisp::Lisp& lisp); + AmbientSound(Vector pos, float factor, float bias, float vol, std::string file); ~AmbientSound(); protected: virtual void hit(Player& player); diff --git a/src/object/infoblock.cpp b/src/object/infoblock.cpp index 02b2ca2ba..2eb7ca2b6 100644 --- a/src/object/infoblock.cpp +++ b/src/object/infoblock.cpp @@ -26,9 +26,7 @@ #include "sprite/sprite_manager.h" #include "object_factory.h" #include "lisp/lisp.h" -#include "audio/sound_manager.h" #include "sector.h" -#include "player.h" InfoBlock::InfoBlock(const lisp::Lisp& lisp) : Block(sprite_manager->create("infoblock")) @@ -41,7 +39,8 @@ InfoBlock::InfoBlock(const lisp::Lisp& lisp) if(!lisp.get("message", message)) { std::cerr << "No message in InfoBlock!\n"; } - ringing = false; + ringing = new AmbientSound(get_pos(), 0.5, 300, 1, "phone"); + Sector::current()->add_object(ringing); } InfoBlock::~InfoBlock() @@ -49,18 +48,11 @@ InfoBlock::~InfoBlock() } void -InfoBlock::update(float elapsed_time) -{ - elapsed_time = 0; - if (ringing) sound_manager->play_sound("phone",get_pos(),Sector::current()->player->get_pos()); -} - -void InfoBlock::hit(Player& ) { GameSession::current()->display_info_box(message); - ringing = false; start_bounce(); + ringing->remove_me(); } IMPLEMENT_FACTORY(InfoBlock, "infoblock") diff --git a/src/object/infoblock.h b/src/object/infoblock.h index 11f9927c6..9f6a670ae 100644 --- a/src/object/infoblock.h +++ b/src/object/infoblock.h @@ -22,6 +22,7 @@ #define __INFOBLOCK_H__ #include "block.h" +#include "object/ambient_sound.h" class InfoBlock : public Block { @@ -31,9 +32,8 @@ public: protected: virtual void hit(Player& player); - virtual void update(float elapsed_time); std::string message; - bool ringing; + AmbientSound* ringing; }; #endif