typedef struct
{
float lifetime; // total lifetime of the particle
float decay; // decay speed of the particle
float r,g,b; // color values of the particle
float xpos,ypos,zpos; // position of the particle
float xspeed,yspeed,zspeed; // speed of the particle
boolean active; // is particle active or not?
} PARTICLE;
void CreateParticle(int i)
{
particle[i].lifetime= (float)random(500000)/500000.0;
particle[i].decay=0.001;
particle[i].r = 0.7;
particle[i].g = 0.7;
particle[i].b = 1.0;
particle[i].xpos= 0.0;
particle[i].ypos= 0.0;
particle[i].zpos= 0.0;
particle[i].xspeed = 0.0005-(float)random(100)/100000.0;
particle[i].yspeed = 0.01-(float)random(100)/100000.0;
particle[i].zspeed = 0.0005-(float)random(100)/100000.0;
particle[i].active = true;
}
How would I go about doing something like this in Java? I think this looks like a good way of doing so I was hoping there is a similar solution in Java.
You could create a
Particleclass:You can also easily make methods to return the values of your data fields, for example: