Particle Class Reference

#include <particle.h>

Inheritance diagram for Particle:

Sprite ImageParticle TextParticle AnimationParticle

List of all members.


Detailed Description

A particle spawned by a ParticleEmitter.

Definition at line 44 of file particle.h.


Public Member Functions

 Particle (Map *map)
 Constructor.
 ~Particle ()
 Destructor.
void clear ()
 Deletes all child particles and emitters.
void setupEngine ()
 Gives a particle the properties of an engine root particle and loads the particle-related config settings.
virtual bool update ()
 Updates particle position, returns false when the particle should be deleted.
virtual void draw (Graphics *graphics, int offsetX, int offsetY) const
 Draws the particle image.
virtual int getPixelY () const
 Necessary for sorting with the other sprites.
void setMap (Map *map)
 Sets the map the particle is on.
ParticleaddEffect (const std::string &particleEffectFile, int pixelX, int pixelY, int rotation=0)
 Creates a child particle that hosts some emitters described in the particleEffectFile.
ParticleaddTextSplashEffect (const std::string &text, int x, int y, const gcn::Color *color, gcn::Font *font, bool outline=false)
 Creates a standalone text particle.
ParticleaddTextRiseFadeOutEffect (const std::string &text, int x, int y, const gcn::Color *color, gcn::Font *font, bool outline=false)
 Creates a standalone text particle.
void addEmitter (ParticleEmitter *emitter)
 Adds an emitter to the particle.
void moveTo (const Vector &pos)
 Sets the position in 3 dimensional space in pixels relative to map.
void moveTo (float x, float y)
 Sets the position in 2 dimensional space in pixels relative to map.
const VectorgetPosition () const
 Returns the particle position.
void moveBy (const Vector &change)
 Changes the particle position relative.
void setLifetime (int lifetime)
 Sets the time in game ticks until the particle is destroyed.
void setFadeOut (int fadeOut)
 Sets the age of the pixel in game ticks where the particle has faded in completely.
void setFadeIn (int fadeIn)
 Sets the remaining particle lifetime where the particle starts to fade out.
void setAlpha (float alpha)
 Sets the alpha value of the particle.
void setSpriteIterator (std::list< Sprite * >::iterator spriteIterator)
 Sets the sprite iterator of the particle on the current map to make it easier to remove the particle from the map when it is destroyed.
std::list< Sprite * >::iterator getSpriteIterator () const
 Gets the sprite iterator of the particle on the current map.
void setVelocity (float x, float y, float z)
 Sets the current velocity in 3 dimensional space.
void setGravity (float gravity)
 Sets the downward acceleration.
void setRandomness (int r)
 Sets the ammount of random vector changes.
void setBounce (float bouncieness)
 Sets the ammount of velocity particles retain after hitting the ground.
void setFollow (bool follow)
 Sets the flag if the particle is supposed to be moved by its parent.
bool doesFollow ()
 Gets the flag if the particle is supposed to be moved by its parent.
void setDestination (Particle *target, float accel, float moment)
 Makes the particle move toward another particle with a given acceleration and momentum.
void setDieDistance (float dist)
 Sets the distance in pixel the particle can come near the target particle before it is destroyed.
bool isAlive ()
bool isExtinct ()
 Determines whether the particle and its children are all dead.
void kill ()
 Manually marks the particle for deletion.
void disableAutoDelete ()
 After calling this function the particle will only request deletion when kill() is called.

Static Public Attributes

static const float PARTICLE_SKY = 800.0f
 Maximum Z position of particles.
static int fastPhysics = 0
 Mode of squareroot calculation.
static int particleCount = 0
 Current number of particles.
static int maxCount = 0
 Maximum number of particles.
static int emitterSkip = 1
 Duration of pause between two emitter updates in ticks.

Protected Attributes

bool mAlive
 Is the particle supposed to be drawn and updated?
Vector mPos
 Position in pixels relative to map.
int mLifetimeLeft
 Lifetime left in game ticks.
int mLifetimePast
 Age of the particle in game ticks.
int mFadeOut
 Lifetime in game ticks left where fading out begins.
int mFadeIn
 Age in game ticks where fading in is finished.
float mAlpha
 Opacity of the graphical representation of the particle.

Private Attributes

bool mAutoDelete
 May the particle request its deletion by the parent particle?
MapmMap
 Map the particle is on.
std::list< Sprite * >::iterator mSpriteIterator
 iterator of the particle on the current map
Emitters mChildEmitters
 List of child emitters.
Particles mChildParticles
 List of particles controlled by this particle.
Vector mVelocity
 Speed in pixels per game-tick.
float mGravity
 Downward acceleration in pixels per game-tick.
int mRandomness
 Ammount of random vector change.
float mBounce
 How much the particle bounces off when hitting the ground.
bool mFollow
 is this particle moved when its parent particle moves?
ParticlemTarget
 The particle that attracts this particle.
float mAcceleration
 Acceleration towards the target particle in pixels per game-tick�.
float mInvDieDistance
 Distance in pixels from the target particle that causes the destruction of the particle.
float mMomentum
 How much speed the particle retains after each game tick.

Constructor & Destructor Documentation

Particle::Particle ( Map map  ) 

Constructor.

Parameters:
map the map this particle will add itself to, may be NULL

Definition at line 53 of file particle.cpp.

Particle::~Particle (  ) 

Destructor.

Definition at line 76 of file particle.cpp.


Member Function Documentation

void Particle::clear (  ) 

Deletes all child particles and emitters.

Definition at line 371 of file particle.cpp.

void Particle::setupEngine (  ) 

Gives a particle the properties of an engine root particle and loads the particle-related config settings.

Definition at line 86 of file particle.cpp.

bool Particle::update (  )  [virtual]

Updates particle position, returns false when the particle should be deleted.

Reimplemented in AnimationParticle.

Definition at line 99 of file particle.cpp.

void Particle::draw ( Graphics graphics,
int  offsetX,
int  offsetY 
) const [virtual]

Draws the particle image.

Implements Sprite.

Reimplemented in ImageParticle, and TextParticle.

Definition at line 95 of file particle.cpp.

virtual int Particle::getPixelY (  )  const [inline, virtual]

Necessary for sorting with the other sprites.

Implements Sprite.

Reimplemented in TextParticle.

Definition at line 90 of file particle.h.

void Particle::setMap ( Map map  ) 

Sets the map the particle is on.

Definition at line 364 of file particle.cpp.

Particle * Particle::addEffect ( const std::string &  particleEffectFile,
int  pixelX,
int  pixelY,
int  rotation = 0 
)

Creates a child particle that hosts some emitters described in the particleEffectFile.

Definition at line 252 of file particle.cpp.

Particle * Particle::addTextSplashEffect ( const std::string &  text,
int  x,
int  y,
const gcn::Color *  color,
gcn::Font *  font,
bool  outline = false 
)

Creates a standalone text particle.

Definition at line 327 of file particle.cpp.

Particle * Particle::addTextRiseFadeOutEffect ( const std::string &  text,
int  x,
int  y,
const gcn::Color *  color,
gcn::Font *  font,
bool  outline = false 
)

Creates a standalone text particle.

Definition at line 346 of file particle.cpp.

void Particle::addEmitter ( ParticleEmitter emitter  )  [inline]

Adds an emitter to the particle.

Definition at line 122 of file particle.h.

void Particle::moveTo ( const Vector pos  )  [inline]

Sets the position in 3 dimensional space in pixels relative to map.

Definition at line 128 of file particle.h.

void Particle::moveTo ( float  x,
float  y 
)

Sets the position in 2 dimensional space in pixels relative to map.

Definition at line 247 of file particle.cpp.

const Vector& Particle::getPosition (  )  const [inline]

Returns the particle position.

Definition at line 139 of file particle.h.

void Particle::moveBy ( const Vector change  ) 

Changes the particle position relative.

Definition at line 234 of file particle.cpp.

void Particle::setLifetime ( int  lifetime  )  [inline]

Sets the time in game ticks until the particle is destroyed.

Definition at line 150 of file particle.h.

void Particle::setFadeOut ( int  fadeOut  )  [inline]

Sets the age of the pixel in game ticks where the particle has faded in completely.

Definition at line 157 of file particle.h.

void Particle::setFadeIn ( int  fadeIn  )  [inline]

Sets the remaining particle lifetime where the particle starts to fade out.

Definition at line 164 of file particle.h.

void Particle::setAlpha ( float  alpha  )  [inline]

Sets the alpha value of the particle.

Definition at line 170 of file particle.h.

void Particle::setSpriteIterator ( std::list< Sprite * >::iterator  spriteIterator  )  [inline]

Sets the sprite iterator of the particle on the current map to make it easier to remove the particle from the map when it is destroyed.

Definition at line 177 of file particle.h.

std::list<Sprite*>::iterator Particle::getSpriteIterator (  )  const [inline]

Gets the sprite iterator of the particle on the current map.

Definition at line 184 of file particle.h.

void Particle::setVelocity ( float  x,
float  y,
float  z 
) [inline]

Sets the current velocity in 3 dimensional space.

Definition at line 190 of file particle.h.

void Particle::setGravity ( float  gravity  )  [inline]

Sets the downward acceleration.

Definition at line 196 of file particle.h.

void Particle::setRandomness ( int  r  )  [inline]

Sets the ammount of random vector changes.

Definition at line 202 of file particle.h.

void Particle::setBounce ( float  bouncieness  )  [inline]

Sets the ammount of velocity particles retain after hitting the ground.

Definition at line 209 of file particle.h.

void Particle::setFollow ( bool  follow  )  [inline]

Sets the flag if the particle is supposed to be moved by its parent.

Definition at line 215 of file particle.h.

bool Particle::doesFollow (  )  [inline]

Gets the flag if the particle is supposed to be moved by its parent.

Definition at line 221 of file particle.h.

void Particle::setDestination ( Particle target,
float  accel,
float  moment 
) [inline]

Makes the particle move toward another particle with a given acceleration and momentum.

Definition at line 228 of file particle.h.

void Particle::setDieDistance ( float  dist  )  [inline]

Sets the distance in pixel the particle can come near the target particle before it is destroyed.

Does only make sense after a target particle has been set using setDestination.

Definition at line 236 of file particle.h.

bool Particle::isAlive (  )  [inline]

Definition at line 239 of file particle.h.

bool Particle::isExtinct (  )  [inline]

Determines whether the particle and its children are all dead.

Definition at line 245 of file particle.h.

void Particle::kill (  )  [inline]

Manually marks the particle for deletion.

Definition at line 251 of file particle.h.

void Particle::disableAutoDelete (  )  [inline]

After calling this function the particle will only request deletion when kill() is called.

Definition at line 258 of file particle.h.


Member Data Documentation

const float Particle::PARTICLE_SKY = 800.0f [static]

Maximum Z position of particles.

Definition at line 47 of file particle.h.

int Particle::fastPhysics = 0 [static]

Mode of squareroot calculation.

Definition at line 48 of file particle.h.

int Particle::particleCount = 0 [static]

Current number of particles.

Definition at line 49 of file particle.h.

int Particle::maxCount = 0 [static]

Maximum number of particles.

Definition at line 50 of file particle.h.

int Particle::emitterSkip = 1 [static]

Duration of pause between two emitter updates in ticks.

Definition at line 51 of file particle.h.

bool Particle::mAlive [protected]

Is the particle supposed to be drawn and updated?

Definition at line 262 of file particle.h.

Vector Particle::mPos [protected]

Position in pixels relative to map.

Definition at line 263 of file particle.h.

int Particle::mLifetimeLeft [protected]

Lifetime left in game ticks.

Definition at line 264 of file particle.h.

int Particle::mLifetimePast [protected]

Age of the particle in game ticks.

Definition at line 265 of file particle.h.

int Particle::mFadeOut [protected]

Lifetime in game ticks left where fading out begins.

Definition at line 266 of file particle.h.

int Particle::mFadeIn [protected]

Age in game ticks where fading in is finished.

Definition at line 267 of file particle.h.

float Particle::mAlpha [protected]

Opacity of the graphical representation of the particle.

Definition at line 268 of file particle.h.

bool Particle::mAutoDelete [private]

May the particle request its deletion by the parent particle?

Definition at line 272 of file particle.h.

Map* Particle::mMap [private]

Map the particle is on.

Definition at line 273 of file particle.h.

std::list<Sprite*>::iterator Particle::mSpriteIterator [private]

iterator of the particle on the current map

Definition at line 274 of file particle.h.

List of child emitters.

Definition at line 275 of file particle.h.

List of particles controlled by this particle.

Definition at line 276 of file particle.h.

Speed in pixels per game-tick.

Definition at line 279 of file particle.h.

float Particle::mGravity [private]

Downward acceleration in pixels per game-tick.

Definition at line 280 of file particle.h.

int Particle::mRandomness [private]

Ammount of random vector change.

Definition at line 281 of file particle.h.

float Particle::mBounce [private]

How much the particle bounces off when hitting the ground.

Definition at line 282 of file particle.h.

bool Particle::mFollow [private]

is this particle moved when its parent particle moves?

Definition at line 283 of file particle.h.

The particle that attracts this particle.

Definition at line 286 of file particle.h.

float Particle::mAcceleration [private]

Acceleration towards the target particle in pixels per game-tick�.

Definition at line 287 of file particle.h.

float Particle::mInvDieDistance [private]

Distance in pixels from the target particle that causes the destruction of the particle.

Definition at line 288 of file particle.h.

float Particle::mMomentum [private]

How much speed the particle retains after each game tick.

Definition at line 289 of file particle.h.


The documentation for this class was generated from the following files:

Generated on Sun Apr 26 17:30:43 2009 for The Mana World by  doxygen 1.5.5