diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2008-12-08 20:58:10 +0100 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2008-12-08 21:22:43 +0100 |
commit | 68760426532b9ca4c6939d7a7b8faa1586ee82e0 (patch) | |
tree | 891f475717294eef4c68af4bb830f35744643075 /src/particle.cpp | |
parent | ddc93c461070fb3d868fbb5426e8361d1b93ee38 (diff) | |
download | mana-68760426532b9ca4c6939d7a7b8faa1586ee82e0.tar.gz mana-68760426532b9ca4c6939d7a7b8faa1586ee82e0.tar.bz2 mana-68760426532b9ca4c6939d7a7b8faa1586ee82e0.tar.xz mana-68760426532b9ca4c6939d7a7b8faa1586ee82e0.zip |
Code reformatting
I wish I had never fallen for this weird style, and I hope removing it
will prevent others from introducing new code like this. :-)
Diffstat (limited to 'src/particle.cpp')
-rw-r--r-- | src/particle.cpp | 72 |
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(); } |