added some methods to Particle engine

This commit is contained in:
Ziver Koc 2007-03-26 09:08:35 +00:00
parent 7702b84e7c
commit 3f215573b5

View file

@ -30,9 +30,7 @@ import ei.engine.texture.TextureLoader;
* *
*/ */
public class Particles extends Entity{ public class Particles extends Entity{
public int maxParticles = 1000;
public boolean regenerate = true; public boolean regenerate = true;
public boolean enabled = true;
public boolean rainbow = true; // Rainbow Mode? public boolean rainbow = true; // Rainbow Mode?
public float slowdown = 1.0f; // Slow Down Particles 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} {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 Particle particle[];
private int col; // Current Color Selection private int col; // Current Color Selection
private int delay; // Rainbow Effect Delay private int delay; // Rainbow Effect Delay
private Texture texture; // Storage For Our Particle Texture private Texture texture; // Storage For Our Particle Texture
/**
* Initiats the particle engine
*
* @param name The name of the particle engine
*/
public Particles(String name){ public Particles(String name){
super(name); super(name);
this.texture = TextureLoader.getTextureLoaderInstance().getTexture("data/particle.bmp"); this.texture = TextureLoader.getTextureLoaderInstance().getTexture("data/particle.bmp");
reset(); 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 * Resets all the paricals
* *
@ -110,10 +126,10 @@ public class Particles extends Entity{
} }
} }
private void setExplotion() { private void setDefault() {
MaxSpeedX = 500; MaxSpeedX = 500;
MaxSpeedY = 500; MaxSpeedY = 500;
MaxSpeedZ = 500; MaxSpeedZ = 0;
pullForceX = 0.0f; pullForceX = 0.0f;
pullForceY = 0.0f; pullForceY = 0.0f;
@ -203,6 +219,33 @@ public class Particles extends Entity{
GL11.glPopMatrix(); 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<particle.length ;i++){
particle[i].active = true;
}
}
} }
class Particle { // Particles Structure class Particle { // Particles Structure