summaryrefslogtreecommitdiff
path: root/src/particle.cpp
diff options
context:
space:
mode:
authorPhilipp Sehmisch <tmw@crushnet.org>2008-06-24 12:29:33 +0000
committerPhilipp Sehmisch <tmw@crushnet.org>2008-06-24 12:29:33 +0000
commitbea93daec3ad4e3345c701e5dcce250c44d128f2 (patch)
treeb8056f0d9ec3f634cf21c21e86a06094a43eb6fa /src/particle.cpp
parent5f391618757e93c010141380583ff487848286da (diff)
downloadmana-client-bea93daec3ad4e3345c701e5dcce250c44d128f2.tar.gz
mana-client-bea93daec3ad4e3345c701e5dcce250c44d128f2.tar.bz2
mana-client-bea93daec3ad4e3345c701e5dcce250c44d128f2.tar.xz
mana-client-bea93daec3ad4e3345c701e5dcce250c44d128f2.zip
Added particle property "follow-parent" which makes the particle move when its parent particle is moved.
Diffstat (limited to 'src/particle.cpp')
-rw-r--r--src/particle.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/particle.cpp b/src/particle.cpp
index fd45430c..3b3f5116 100644
--- a/src/particle.cpp
+++ b/src/particle.cpp
@@ -63,6 +63,7 @@ Particle::Particle(Map *map):
mGravity(0.0f),
mRandomnes(0),
mBounce(0.0f),
+ mFollow(false),
mTarget(NULL),
mAcceleration(0.0f),
mInvDieDistance(-1.0f),
@@ -95,6 +96,8 @@ Particle::update()
mAlive = false;
}
+ Vector oldPos = mPos;
+
if (mAlive)
{
//calculate particle movement
@@ -191,10 +194,19 @@ Particle::update()
}
}
+ Vector change = mPos - oldPos;
+
// Update child particles
+
for (ParticleIterator p = mChildParticles.begin();
p != mChildParticles.end();)
{
+ //move particle with its parent if desired
+ if ((*p)->doesFollow())
+ {
+ (*p)->moveBy(change);
+ }
+ //update particle
if ((*p)->update())
{
p++;