summaryrefslogtreecommitdiff
path: root/src/particle.cpp
diff options
context:
space:
mode:
authorIra Rice <irarice@gmail.com>2009-03-17 20:18:41 -0600
committerIra Rice <irarice@gmail.com>2009-03-17 20:18:41 -0600
commit72daf0bf49c0ff994aeff357f6e52140887bce30 (patch)
tree6965511cc5bbede09526c115d43fc1465f39f7de /src/particle.cpp
parenta1eb62126bae54557e03682cac70c8331e359e01 (diff)
downloadmana-72daf0bf49c0ff994aeff357f6e52140887bce30.tar.gz
mana-72daf0bf49c0ff994aeff357f6e52140887bce30.tar.bz2
mana-72daf0bf49c0ff994aeff357f6e52140887bce30.tar.xz
mana-72daf0bf49c0ff994aeff357f6e52140887bce30.zip
Added an image merge feature loosely based on a merge function found in
the open source project Wormux. To improve SDL performance, the number of layers that are pushed out to the hardware or software buffers should be reduced, which is where this function comes into play, as it combines two surfaces together so that the number of blit operations is reduced. This function is currently not used, but will be used once a good way to link each of the target systems is determined so that it only initiates when SDL is enabled, as well as making sure that each hook that uses this function is benefiting from it sufficiently. At the moment, it's suspected that the particle engine will likely be the most likely to benefit from this function, followed by tile drawing, then sprite drawing. Signed-off-by: Ira Rice <irarice@gmail.com>
Diffstat (limited to 'src/particle.cpp')
-rw-r--r--src/particle.cpp44
1 files changed, 24 insertions, 20 deletions
diff --git a/src/particle.cpp b/src/particle.cpp
index e56435ed..0e412ada 100644
--- a/src/particle.cpp
+++ b/src/particle.cpp
@@ -177,7 +177,8 @@ bool Particle::update()
mVelocity *= mBounce;
mVelocity.z = -mVelocity.z;
}
- else {
+ else
+ {
mAlive = false;
}
}
@@ -185,16 +186,12 @@ bool Particle::update()
// Update child emitters
if ((mLifetimePast-1)%Particle::emitterSkip == 0)
{
- for ( EmitterIterator e = mChildEmitters.begin();
- e != mChildEmitters.end();
- e++
- )
+ for (EmitterIterator e = mChildEmitters.begin();
+ e != mChildEmitters.end(); e++)
{
Particles newParticles = (*e)->createParticles(mLifetimePast);
- for ( ParticleIterator p = newParticles.begin();
- p != newParticles.end();
- p++
- )
+ for (ParticleIterator p = newParticles.begin();
+ p != newParticles.end(); p++)
{
(*p)->moveBy(mPos);
mChildParticles.push_back (*p);
@@ -219,7 +216,9 @@ bool Particle::update()
if ((*p)->update())
{
p++;
- } else {
+ }
+ else
+ {
delete (*p);
p = mChildParticles.erase(p);
}
@@ -237,8 +236,7 @@ void Particle::moveBy(const Vector &change)
{
mPos += change;
for (ParticleIterator p = mChildParticles.begin();
- p != mChildParticles.end();
- p++)
+ p != mChildParticles.end(); p++)
{
if ((*p)->doesFollow())
{
@@ -279,20 +277,21 @@ Particle* Particle::addEffect(const std::string &particleEffectFile,
xmlNodePtr node;
// Animation
- if ((node = XML::findFirstChildByName(
- effectChildNode, "animation"))) {
+ if ((node = XML::findFirstChildByName(effectChildNode, "animation")))
+ {
newParticle = new AnimationParticle(mMap, node);
}
// Image
- else if ((node = XML::findFirstChildByName(
- effectChildNode, "image"))) {
+ else if ((node = XML::findFirstChildByName(effectChildNode, "image")))
+ {
Image *img= resman->getImage((const char*)
node->xmlChildrenNode->content);
newParticle = new ImageParticle(mMap, img);
}
// Other
- else {
+ else
+ {
newParticle = new Particle(mMap);
}
@@ -315,7 +314,8 @@ Particle* Particle::addEffect(const std::string &particleEffectFile,
continue;
ParticleEmitter *newEmitter;
- newEmitter = new ParticleEmitter(emitterNode, newParticle, mMap, rotation);
+ newEmitter = new ParticleEmitter(emitterNode, newParticle, mMap,
+ rotation);
newParticle->addEmitter(newEmitter);
}
@@ -326,7 +326,8 @@ Particle* Particle::addEffect(const std::string &particleEffectFile,
}
Particle *Particle::addTextSplashEffect(const std::string &text, int x, int y,
- const gcn::Color *color, gcn::Font *font, bool outline)
+ const gcn::Color *color,
+ gcn::Font *font, bool outline)
{
Particle *newParticle = new TextParticle(mMap, text, color, font, outline);
newParticle->moveTo(x, y);
@@ -344,7 +345,10 @@ Particle *Particle::addTextSplashEffect(const std::string &text, int x, int y,
}
Particle *Particle::addTextRiseFadeOutEffect(const std::string &text,
- int x, int y, const gcn::Color *color, gcn::Font *font, bool outline){
+ int x, int y,
+ const gcn::Color *color,
+ gcn::Font *font, bool outline)
+{
Particle *newParticle = new TextParticle(mMap, text, color, font, outline);
newParticle->moveTo(x, y);
newParticle->setVelocity(0.0f, 0.0f, 0.5f);