#include <flame.hpp>
Inherits BadGuy.
Public Member Functions | |
Flame (const Reader &reader) | |
Flame (const Flame &flame) | |
void | activate () |
called when the badguy has been activated. | |
void | deactivate () |
called when the badguy has been deactivated | |
void | active_update (float elapsed_time) |
called each frame when the badguy is activated. | |
void | kill_fall () |
Set the badguy to kill/falling state, which makes him falling of the screen (his sprite is turned upside-down). | |
Private Attributes | |
float | angle |
float | radius |
float | speed |
std::auto_ptr< SoundSource > | sound_source |
Definition at line 24 of file flame.hpp.
Flame::Flame | ( | const Reader & | reader | ) |
Definition at line 27 of file flame.cpp.
References angle, MovingObject::bbox, COLGROUP_TOUCHABLE, BadGuy::countMe, FLAME_SOUND, lisp::Lisp::get(), SoundManager::preload(), radius, BadGuy::set_colgroup_active(), Rectf::set_pos(), sound_manager, speed, BadGuy::start_position, Vector::x, and Vector::y.
00027 : 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 }
Flame::Flame | ( | const Flame & | flame | ) |
void Flame::activate | ( | ) | [virtual] |
called when the badguy has been activated.
(As a side effect the dir variable might have been changed so that it faces towards the player.
Reimplemented from BadGuy.
Definition at line 56 of file flame.cpp.
References SoundManager::create_sound_source(), FLAME_SOUND, MovingObject::get_pos(), sound_manager, and sound_source.
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 }
void Flame::deactivate | ( | ) | [virtual] |
called when the badguy has been deactivated
Reimplemented from BadGuy.
Definition at line 67 of file flame.cpp.
References sound_source.
00068 { 00069 sound_source.reset(); 00070 }
void Flame::active_update | ( | float | elapsed_time | ) | [virtual] |
called each frame when the badguy is activated.
Reimplemented from BadGuy.
Definition at line 45 of file flame.cpp.
References angle, MovingObject::get_pos(), MovingObject::movement, radius, sound_source, speed, BadGuy::start_position, Vector::x, and Vector::y.
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 }
void Flame::kill_fall | ( | ) | [virtual] |
float Flame::angle [private] |
float Flame::radius [private] |
float Flame::speed [private] |
std::auto_ptr<SoundSource> Flame::sound_source [private] |
Definition at line 41 of file flame.hpp.
Referenced by activate(), active_update(), and deactivate().