From fbbb9658d4d90a1080d28f3a720d2777939e8cb6 Mon Sep 17 00:00:00 2001 From: Philipp Sehmisch Date: Sun, 14 Dec 2008 17:03:30 +0100 Subject: Passing vectors by reference --- src/particle.cpp | 45 ++++++++++++++++++++++----------------------- 1 file changed, 22 insertions(+), 23 deletions(-) (limited to 'src/particle.cpp') diff --git a/src/particle.cpp b/src/particle.cpp index f73bd222..1f067de3 100644 --- a/src/particle.cpp +++ b/src/particle.cpp @@ -228,26 +228,25 @@ bool Particle::update() } return true; -} - -void Particle::moveBy(Vector change) -{ - mPos += change; - for (ParticleIterator p = mChildParticles.begin(); - p != mChildParticles.end(); - p++) - { - if ((*p)->doesFollow()) - { - (*p)->moveBy(change); - } - } - return; -} - -void Particle::moveTo(float x, float y) -{ - moveTo(Vector(x, y, mPos.z)); +} + +void Particle::moveBy(const Vector &change) +{ + mPos += change; + for (ParticleIterator p = mChildParticles.begin(); + p != mChildParticles.end(); + p++) + { + if ((*p)->doesFollow()) + { + (*p)->moveBy(change); + } + } +} + +void Particle::moveTo(float x, float y) +{ + moveTo(Vector(x, y, mPos.z)); } Particle* Particle::addEffect(const std::string &particleEffectFile, @@ -297,12 +296,12 @@ Particle* Particle::addEffect(const std::string &particleEffectFile, // Read and set the basic properties of the particle float offsetX = XML::getFloatProperty(effectChildNode, "position-x", 0); float offsetY = XML::getFloatProperty(effectChildNode, "position-y", 0); - float offsetZ = XML::getFloatProperty(effectChildNode, "position-z", 0); + float offsetZ = XML::getFloatProperty(effectChildNode, "position-z", 0); Vector position (mPos.x + (float)pixelX + offsetX, mPos.y + (float)pixelY + offsetY, mPos.z + offsetZ); - newParticle->moveTo(position); - + newParticle->moveTo(position); + int lifetime = XML::getProperty(effectChildNode, "lifetime", -1); newParticle->setLifetime(lifetime); -- cgit v1.2.3-70-g09d2