ArrayList<Particle> particles;
void setup(){
size(640, 480, P3D);
particles = new ArrayList<Particle>();
for(int i = 0; i < 500; i++){
particles.add(new Particle());
}
noStroke();
fill(255, 255, 56);
sphereDetail(8);
}
void draw(){
background(25, 25, 112);
translate(0, height / 2);
for(Particle particle: particles){
particle.update();
particle.display();
}
}
class Particle{
float x;
float radian;
Particle(){
x = random(-200, width + 200);
radian = random(TWO_PI);
}
void update(){
radian += PI / 256;
}
void display(){
pushMatrix();
translate(x, height / 2.0 * sin(radian), height / 2.0 * cos(radian));
sphere(10);
popMatrix();
}
}