Flame Class Reference

#include <flame.hpp>

Inherits BadGuy.

List of all members.

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< SoundSourcesound_source


Detailed Description

Definition at line 24 of file flame.hpp.


Constructor & Destructor Documentation

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  ) 


Member Function Documentation

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]

Set the badguy to kill/falling state, which makes him falling of the screen (his sprite is turned upside-down).

Reimplemented from BadGuy.

Definition at line 73 of file flame.cpp.

00074 {
00075 }


Member Data Documentation

float Flame::angle [private]

Definition at line 37 of file flame.hpp.

Referenced by active_update(), and Flame().

float Flame::radius [private]

Definition at line 38 of file flame.hpp.

Referenced by active_update(), and Flame().

float Flame::speed [private]

Definition at line 39 of file flame.hpp.

Referenced by active_update(), and Flame().

std::auto_ptr<SoundSource> Flame::sound_source [private]

Definition at line 41 of file flame.hpp.

Referenced by activate(), active_update(), and deactivate().


The documentation for this class was generated from the following files:
Generated on Mon Jun 9 03:38:30 2014 for SuperTux by  doxygen 1.5.1