summaryrefslogtreecommitdiff
path: root/src/particle.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/particle.cpp')
-rw-r--r--src/particle.cpp72
1 files changed, 32 insertions, 40 deletions
diff --git a/src/particle.cpp b/src/particle.cpp
index d4266df2..e534527f 100644
--- a/src/particle.cpp
+++ b/src/particle.cpp
@@ -68,12 +68,21 @@ Particle::Particle(Map *map):
mMomentum(1.0f)
{
Particle::particleCount++;
- if (mMap) setSpriteIterator(mMap->addSprite(this));
+ if (mMap)
+ setSpriteIterator(mMap->addSprite(this));
}
+Particle::~Particle()
+{
+ // Remove from map sprite list
+ if (mMap)
+ mMap->removeSprite(mSpriteIterator);
+ // Delete child emitters and child particles
+ clear();
+ Particle::particleCount--;
+}
-void
-Particle::setupEngine()
+void Particle::setupEngine()
{
Particle::maxCount = (int)config.getValue("particleMaxCount", 3000);
Particle::fastPhysics = (int)config.getValue("particleFastPhysics", 0);
@@ -82,17 +91,17 @@ Particle::setupEngine()
logger->log("Particle engine set up");
}
-void Particle::draw(Graphics *, int, int) const {}
+void Particle::draw(Graphics *, int, int) const
+{
+}
-bool
-Particle::update()
+bool Particle::update()
{
- if (!mMap) return false;
+ if (!mMap)
+ return false;
if (mLifetimeLeft == 0)
- {
mAlive = false;
- }
Vector oldPos = mPos;
@@ -222,9 +231,8 @@ Particle::update()
return true;
}
-Particle*
-Particle::addEffect(const std::string &particleEffectFile,
- int pixelX, int pixelY)
+Particle *Particle::addEffect(const std::string &particleEffectFile,
+ int pixelX, int pixelY)
{
Particle *newParticle = NULL;
@@ -298,11 +306,9 @@ Particle::addEffect(const std::string &particleEffectFile,
return newParticle;
}
-
-Particle*
-Particle::addTextSplashEffect(const std::string &text,
- int colorR, int colorG, int colorB,
- gcn::Font *font, int x, int y)
+Particle *Particle::addTextSplashEffect(const std::string &text,
+ int colorR, int colorG, int colorB,
+ gcn::Font *font, int x, int y)
{
Particle *newParticle = new TextParticle(mMap, text, colorR, colorG, colorB,
font);
@@ -320,9 +326,9 @@ Particle::addTextSplashEffect(const std::string &text,
return newParticle;
}
-Particle*
-Particle::addTextRiseFadeOutEffect(const std::string &text, gcn::Font *font,
- int x, int y)
+Particle *Particle::addTextRiseFadeOutEffect(const std::string &text,
+ gcn::Font *font,
+ int x, int y)
{
Particle *newParticle = new TextParticle(mMap, text, 255, 255, 255, font);
newParticle->setPosition(x, y, 0);
@@ -337,32 +343,18 @@ Particle::addTextRiseFadeOutEffect(const std::string &text, gcn::Font *font,
return newParticle;
}
-void
-Particle::setMap(Map *map)
+void Particle::setMap(Map *map)
{
mMap = map;
- if (mMap) setSpriteIterator(mMap->addSprite(this));
+ if (mMap)
+ setSpriteIterator(mMap->addSprite(this));
}
-
-Particle::~Particle()
-{
- // Remove from map sprite list
- if (mMap) mMap->removeSprite(mSpriteIterator);
- // Delete child emitters and child particles
- clear();
- Particle::particleCount--;
-}
-
-
-void
-Particle::clear()
+void Particle::clear()
{
- std::for_each(mChildEmitters.begin(), mChildEmitters.end(),
- make_dtor(mChildEmitters));
+ delete_all(mChildEmitters);
mChildEmitters.clear();
- std::for_each(mChildParticles.begin(), mChildParticles.end(),
- make_dtor(mChildParticles));
+ delete_all(mChildParticles);
mChildParticles.clear();
}