Particle system_useArrayList & Rectangle

ANIMATION
import java.awt.Rectangle;

ArrayList particles;
Rectangle blackhole;

void setup(){
  size(600,400);
  pixelDensity(2);
  particles=new ArrayList();
  blackhole=new Rectangle(60,height-100,width-120,30);
}

void draw(){
  background(255);
  //Create a new particle once a circle
  particles.add(new Particle(mouseX,mouseY));
  
  fill(200);
  rect(blackhole.x, blackhole.y,blackhole.width,blackhole.height);
  
  for(int i=0;i1000){
    particles.remove(0);
  }
  
  saveFrame("frames/Particle####.jpg");
}

class Particle {
  float x, y, r;
  float c;
  float spx,spy;
  
  Particle(float x_, float y_) {
    x=x_;
    y=y_;
    r=15;
    c=random(10,50);
    spx=random(-1,1);
    spy=random(-4,0);
  }

  void display() {
    fill(255,c*5,c, c);
    noStroke();
    ellipse(x, y, r*2, r*2);
  }

  void move() {
    if (y

你可能感兴趣的:(Particle system_useArrayList & Rectangle)