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();
}
{
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);
#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"))
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()
}
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")
#define __INFOBLOCK_H__
#include "block.h"
+#include "object/ambient_sound.h"
class InfoBlock : public Block
{
protected:
virtual void hit(Player& player);
- virtual void update(float elapsed_time);
std::string message;
- bool ringing;
+ AmbientSound* ringing;
};
#endif