Changed Entity to 3d axis and added a fpstimer that calculates the fps

This commit is contained in:
Ziver Koc 2007-03-27 17:51:02 +00:00
parent ec551064c4
commit 28c3cd0529
11 changed files with 222 additions and 72 deletions

View file

@ -73,7 +73,40 @@ public class Particles extends Entity{
reset();
setDefault();
}
private void setDefault() {
MaxSpeedX = 500;
MaxSpeedY = 500;
MaxSpeedZ = 0;
pullForceX = 0.0f;
pullForceY = 0.0f;
pullForceZ = 0.0f;
life = 1.0f;
size = 20.0f;
regenerate = true;
init();
}
private void init() {
for (int i=0;i<maxParticles;i++){ // Initials All The Textures
particle[i].active = true; // Make All The Particles Active
particle[i].life = life; // Give All The Particles Full Life
particle[i].fade = ((float)(Math.random() * 100.0)) / 1000.0f + 0.003f; // Random Fade Speed
particle[i].r = colors[i * (colors.length / maxParticles)][0]; // Select Red Rainbow Color
particle[i].g = colors[i * (colors.length / maxParticles)][1]; // Select Red Rainbow Color
particle[i].b = colors[i * (colors.length / maxParticles)][2]; // Select Red Rainbow Color
particle[i].xi = ((float)((Math.random() * MaxSpeedX)) - (MaxSpeedX/2)) * 10.0f; // Random Speed On X Axis
particle[i].yi = ((float)((Math.random() * MaxSpeedY)) - (MaxSpeedY/2)) * 10.0f; // Random Speed On Y Axis
particle[i].zi = ((float)((Math.random() * MaxSpeedZ)) - (MaxSpeedZ/2)) * 10.0f; // Random Speed On Z Axis
particle[i].xg = pullForceX; // Set Horizontal Pull To Zero
particle[i].yg = pullForceY; // Set Vertical Pull Downward
particle[i].zg = pullForceZ; // Set Pull On Z Axis To Zero
}
}
/**
* Set the number of particles
* WARNING this will reset all the particles!!
@ -98,6 +131,9 @@ public class Particles extends Entity{
}
}
/**
* Updates the particles
*/
public void update() {
if(rainbow && (delay > 25)) {
delay = 0; // Reset The Rainbow Color Cycling Delay
@ -109,39 +145,9 @@ public class Particles extends Entity{
delay++; // Increase Rainbow Mode Color Cycling Delay Counter
}
private void init() {
for (int i=0;i<maxParticles;i++){ // Initials All The Textures
particle[i].active = true; // Make All The Particles Active
particle[i].life = life; // Give All The Particles Full Life
particle[i].fade = ((float)(Math.random() * 100.0)) / 1000.0f + 0.003f; // Random Fade Speed
particle[i].r = colors[i * (colors.length / maxParticles)][0]; // Select Red Rainbow Color
particle[i].g = colors[i * (colors.length / maxParticles)][1]; // Select Red Rainbow Color
particle[i].b = colors[i * (colors.length / maxParticles)][2]; // Select Red Rainbow Color
particle[i].xi = ((float)((Math.random() * MaxSpeedX)) - (MaxSpeedX/2)) * 10.0f; // Random Speed On X Axis
particle[i].yi = ((float)((Math.random() * MaxSpeedY)) - (MaxSpeedY/2)) * 10.0f; // Random Speed On Y Axis
particle[i].zi = ((float)((Math.random() * MaxSpeedZ)) - (MaxSpeedZ/2)) * 10.0f; // Random Speed On Z Axis
particle[i].xg = pullForceX; // Set Horizontal Pull To Zero
particle[i].yg = pullForceY; // Set Vertical Pull Downward
particle[i].zg = pullForceZ; // Set Pull On Z Axis To Zero
}
}
private void setDefault() {
MaxSpeedX = 500;
MaxSpeedY = 500;
MaxSpeedZ = 0;
pullForceX = 0.0f;
pullForceY = 0.0f;
pullForceZ = 0.0f;
life = 1.0f;
size = 20.0f;
//regenerate = false;
init();
}
/**
* Draw the particles
*/
public void render() {
if(enabled){
// store the current model matrix
@ -193,7 +199,7 @@ public class Particles extends Entity{
particle[i].x = getLocation().getX(); // Center On X Axis
particle[i].y = getLocation().getY(); // Center On Y Axis
particle[i].z = getZ(); // Center On Z Axis
particle[i].z = getLocation().getZ(); // Center On Z Axis
particle[i].xi = xspeed + ((float)((Math.random() * MaxSpeedX)) - (MaxSpeedX/2)) * 10.0f; // X Axis Speed And Direction
particle[i].yi = yspeed + ((float)((Math.random() * MaxSpeedY)) - (MaxSpeedY/2)) * 10.0f; // Y Axis Speed And Direction