summaryrefslogtreecommitdiff
path: root/src/particle.h
diff options
context:
space:
mode:
authorPhilipp Sehmisch <mana@crushnet.org>2010-10-17 17:15:21 +0200
committerPhilipp Sehmisch <mana@crushnet.org>2010-10-17 17:15:21 +0200
commit1b21442b5eb6dcc41a585715d07c73ed3ad59a1b (patch)
treec84f226695e1d7bb7d95fcba7c9e8c30333508da /src/particle.h
parent1f3c056323de16cbe5965e1d65a69eeab73396ce (diff)
downloadmana-client-1b21442b5eb6dcc41a585715d07c73ed3ad59a1b.tar.gz
mana-client-1b21442b5eb6dcc41a585715d07c73ed3ad59a1b.tar.bz2
mana-client-1b21442b5eb6dcc41a585715d07c73ed3ad59a1b.tar.xz
mana-client-1b21442b5eb6dcc41a585715d07c73ed3ad59a1b.zip
Added death effects to particle engine.
Every particle can now have a death effect. This is an effect which is created when the particle dies. Which death reasons (timeout, touching floor, touching sky, reaching target or deleted by external call) trigger the effect can also be specified. This is useful for exploding projectiles and many other effects. Reviewed-by: Bertram
Diffstat (limited to 'src/particle.h')
-rw-r--r--src/particle.h30
1 files changed, 23 insertions, 7 deletions
diff --git a/src/particle.h b/src/particle.h
index 2be169c1..8aa9e5f2 100644
--- a/src/particle.h
+++ b/src/particle.h
@@ -44,6 +44,16 @@ typedef Emitters::iterator EmitterIterator;
class Particle : public Actor
{
public:
+ enum AliveStatus
+ {
+ ALIVE = 0,
+ DEAD_TIMEOUT = 1,
+ DEAD_FLOOR = 2,
+ DEAD_SKY = 4,
+ DEAD_IMPACT = 8,
+ DEAD_OTHER = 16,
+ DEAD_LONG_AGO = 128
+ };
static const float PARTICLE_SKY; /**< Maximum Z position of particles */
static int fastPhysics; /**< Mode of squareroot calculation */
static int particleCount; /**< Current number of particles */
@@ -221,20 +231,20 @@ class Particle : public Actor
void setAllowSizeAdjust(bool adjust)
{ mAllowSizeAdjust = adjust; }
- bool isAlive()
- { return mAlive; }
+ bool isAlive() const
+ { return mAlive == ALIVE; }
/**
* Determines whether the particle and its children are all dead
*/
- bool isExtinct()
+ bool isExtinct() const
{ return !isAlive() && mChildParticles.empty(); }
/**
* Manually marks the particle for deletion.
*/
void kill()
- { mAlive = false; mAutoDelete = true; }
+ { mAlive = DEAD_OTHER; mAutoDelete = true; }
/**
* After calling this function the particle will only request
@@ -252,22 +262,28 @@ class Particle : public Actor
virtual void setAlpha(float alpha) {}
+ virtual void setDeathEffect(const std::string &effectFile, char conditions)
+ { mDeathEffect = effectFile; mDeathEffectConditions = conditions; }
+
protected:
- bool mAlive; /**< Is the particle supposed to be drawn and updated?*/
+ float mAlpha; /**< Opacity of the graphical representation of the particle */
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 */
+ Vector mVelocity; /**< Speed in pixels per game-tick. */
+ private:
+ AliveStatus mAlive; /**< Is the particle supposed to be drawn and updated?*/
// generic properties
bool mAutoDelete; /**< May the particle request its deletion by the parent particle? */
Emitters mChildEmitters; /**< List of child emitters. */
Particles mChildParticles; /**< List of particles controlled by this particle */
bool mAllowSizeAdjust; /**< Can the effect size be adjusted by the object props in the map file? */
+ std::string mDeathEffect; /**< Particle effect file to be spawned when the particle dies */
+ char mDeathEffectConditions;/**< Bitfield of death conditions which trigger spawning of the death particle */
// dynamic 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 */