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;
}
我将如何在 Java 中做这样的事情?我认为这看起来是一种很好的方法,所以我希望 Java 中有类似的解决方案。