xxxxxxxxxx
ArrayList < Particle > particles = new ArrayList < Particle > ();
PVector gravity;
void setup(){
size(800,800);
particles.add(new Particle(width/2, height/2));
gravity = new PVector(-0.01, -0.01);
}
void draw(){
background(255, 255, 255, 127);
for(int i = 0; i < 5; i++){
particles.add(new Particle(mouseX, mouseY));
}
for(int i = particles.size() - 1; i >= 0; i--){
Particle p = particles.get(i);
if(!p.inBounds()){
particles.remove(i);
}
else{
p.applyForce(gravity);
p.move();
p.display();
}
}
}