#include <particle.h>
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. | |
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. | |
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. | |
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. | |
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 Vector & | getPosition () 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? | |
Map * | mMap |
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? | |
Particle * | mTarget |
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. |
Particle::Particle | ( | Map * | map | ) |
Constructor.
map | the map this particle will add itself to, may be NULL |
Definition at line 53 of file particle.cpp.
Particle::~Particle | ( | ) |
void Particle::clear | ( | ) |
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 | ) |
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 | |||
) |
Particle * Particle::addTextRiseFadeOutEffect | ( | const std::string & | text, | |
int | x, | |||
int | y, | |||
const gcn::Color * | color, | |||
gcn::Font * | font, | |||
bool | outline = false | |||
) |
void Particle::addEmitter | ( | ParticleEmitter * | emitter | ) | [inline] |
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] |
void Particle::moveBy | ( | const Vector & | change | ) |
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] |
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] |
void Particle::setGravity | ( | float | gravity | ) | [inline] |
void Particle::setRandomness | ( | int | r | ) | [inline] |
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] |
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.
const float Particle::PARTICLE_SKY = 800.0f [static] |
int Particle::fastPhysics = 0 [static] |
int Particle::particleCount = 0 [static] |
int Particle::maxCount = 0 [static] |
int Particle::emitterSkip = 1 [static] |
bool Particle::mAlive [protected] |
Vector Particle::mPos [protected] |
int Particle::mLifetimeLeft [protected] |
int Particle::mLifetimePast [protected] |
int Particle::mFadeOut [protected] |
int Particle::mFadeIn [protected] |
float Particle::mAlpha [protected] |
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] |
std::list<Sprite*>::iterator Particle::mSpriteIterator [private] |
Emitters Particle::mChildEmitters [private] |
Particles Particle::mChildParticles [private] |
Vector Particle::mVelocity [private] |
float Particle::mGravity [private] |
int Particle::mRandomness [private] |
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] |
Particle* Particle::mTarget [private] |
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.