summaryrefslogtreecommitdiff
path: root/src/particleemitter.cpp
diff options
context:
space:
mode:
authorPhilipp Sehmisch <mana@crushnet.org>2010-03-04 21:27:16 +0100
committerPhilipp Sehmisch <mana@crushnet.org>2010-03-04 21:38:24 +0100
commitc176df1796a7b0fd53b52b52e8bd9d4a81ff8b1a (patch)
tree1b6a239f8fcc7f7834062e76ee2cdf125e9d426d /src/particleemitter.cpp
parent6e68568d9fb44762e4c3257b505e8b67ac1f70fe (diff)
downloadmana-client-c176df1796a7b0fd53b52b52e8bd9d4a81ff8b1a.tar.gz
mana-client-c176df1796a7b0fd53b52b52e8bd9d4a81ff8b1a.tar.bz2
mana-client-c176df1796a7b0fd53b52b52e8bd9d4a81ff8b1a.tar.xz
mana-client-c176df1796a7b0fd53b52b52e8bd9d4a81ff8b1a.zip
Implemented markers for warp portals defined in map files in form of particle effects. Reviewed-by: Jared Adams <jaxad0127@gmail.com>
Diffstat (limited to 'src/particleemitter.cpp')
-rw-r--r--src/particleemitter.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/particleemitter.cpp b/src/particleemitter.cpp
index ee434140..dc9931a5 100644
--- a/src/particleemitter.cpp
+++ b/src/particleemitter.cpp
@@ -474,3 +474,28 @@ std::list<Particle *> ParticleEmitter::createParticles(int tick)
return newParticles;
}
+
+void ParticleEmitter::adjustSize(int w, int h)
+{
+ if (w == 0 || h == 0) return; // new dimensions are illegal
+
+ // calculate the old rectangle
+ int oldWidth = mParticlePosX.maxVal - mParticlePosX.minVal;
+ int oldHeight = mParticlePosX.maxVal - mParticlePosY.minVal;
+ int oldArea = oldWidth * oldHeight;
+ if (oldArea == 0)
+ {
+ //when the effect has no dimension it is
+ //not designed to be resizeable
+ return;
+ }
+
+ // set the new dimensions
+ mParticlePosX.set(0, w);
+ mParticlePosY.set(0, h);
+ int newArea = w * h;
+ // adjust the output so that the particle density stays the same
+ float outputFactor = (float)newArea / (float)oldArea;
+ mOutput.minVal *= outputFactor;
+ mOutput.maxVal *= outputFactor;
+}