From 3f215573b5b83900d0868e9160457393b5986e22 Mon Sep 17 00:00:00 2001 From: Ziver Koc Date: Mon, 26 Mar 2007 09:08:35 +0000 Subject: [PATCH] added some methods to Particle engine --- src/ei/engine/effects/Particles.java | 55 +++++++++++++++++++++++++--- 1 file changed, 49 insertions(+), 6 deletions(-) diff --git a/src/ei/engine/effects/Particles.java b/src/ei/engine/effects/Particles.java index bb97de0..4d0b2c3 100644 --- a/src/ei/engine/effects/Particles.java +++ b/src/ei/engine/effects/Particles.java @@ -30,9 +30,7 @@ import ei.engine.texture.TextureLoader; * */ public class Particles extends Entity{ - public int maxParticles = 1000; public boolean regenerate = true; - public boolean enabled = true; public boolean rainbow = true; // Rainbow Mode? public float slowdown = 1.0f; // Slow Down Particles @@ -57,18 +55,36 @@ public class Particles extends Entity{ {0.5f,0.5f,1.0f},{0.75f,0.5f,1.0f},{1.0f,0.5f,1.0f},{1.0f,0.5f,0.75f} }; + private int maxParticles = 1000; + private boolean enabled = true; private Particle particle[]; private int col; // Current Color Selection private int delay; // Rainbow Effect Delay private Texture texture; // Storage For Our Particle Texture + /** + * Initiats the particle engine + * + * @param name The name of the particle engine + */ public Particles(String name){ super(name); this.texture = TextureLoader.getTextureLoaderInstance().getTexture("data/particle.bmp"); reset(); - setExplotion(); + setDefault(); } - + + /** + * Set the number of particles + * WARNING this will reset all the particles!! + * + * @param max The number of particles + */ + public void setMaxParticles(int max){ + maxParticles = max; + reset(); + } + /** * Resets all the paricals * @@ -110,10 +126,10 @@ public class Particles extends Entity{ } } - private void setExplotion() { + private void setDefault() { MaxSpeedX = 500; MaxSpeedY = 500; - MaxSpeedZ = 500; + MaxSpeedZ = 0; pullForceX = 0.0f; pullForceY = 0.0f; @@ -203,6 +219,33 @@ public class Particles extends Entity{ GL11.glPopMatrix(); } } + + /** + * Set if the particle engine is active + * + * @param b The active status of the particle engine + */ + public void setEnabled(boolean b){ + enabled = b; + } + + /** + * Returns if this effect is enabled + * @return If this effect is enabled + */ + public boolean isEnabled(){ + return enabled; + } + + /** + * Activates all the particles + * + */ + public void activateAllParticles(){ + for(int i=0; i