00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include "badguy/flame.hpp"
00018
00019 #include <math.h>
00020
00021 #include "audio/sound_manager.hpp"
00022 #include "supertux/object_factory.hpp"
00023 #include "util/reader.hpp"
00024
00025 static const std::string FLAME_SOUND = "sounds/flame.wav";
00026
00027 Flame::Flame(const Reader& reader) :
00028 BadGuy(reader, "images/creatures/flame/flame.sprite", LAYER_FLOATINGOBJECTS),
00029 angle(0),
00030 radius(100),
00031 speed(2),
00032 sound_source()
00033 {
00034 reader.get("radius", radius);
00035 reader.get("speed", speed);
00036 bbox.set_pos(Vector(start_position.x + cos(angle) * radius,
00037 start_position.y + sin(angle) * radius));
00038 countMe = false;
00039 sound_manager->preload(FLAME_SOUND);
00040
00041 set_colgroup_active(COLGROUP_TOUCHABLE);
00042 }
00043
00044 void
00045 Flame::active_update(float elapsed_time)
00046 {
00047 angle = fmodf(angle + elapsed_time * speed, (float) (2*M_PI));
00048 Vector newpos(start_position.x + cos(angle) * radius,
00049 start_position.y + sin(angle) * radius);
00050 movement = newpos - get_pos();
00051
00052 sound_source->set_position(get_pos());
00053 }
00054
00055 void
00056 Flame::activate()
00057 {
00058 sound_source.reset(sound_manager->create_sound_source(FLAME_SOUND));
00059 sound_source->set_position(get_pos());
00060 sound_source->set_looping(true);
00061 sound_source->set_gain(2.0);
00062 sound_source->set_reference_distance(32);
00063 sound_source->play();
00064 }
00065
00066 void
00067 Flame::deactivate()
00068 {
00069 sound_source.reset();
00070 }
00071
00072 void
00073 Flame::kill_fall()
00074 {
00075 }
00076
00077