Strahlen-Übung

AnneRoesch

Hier seht ihr die zweite Aufgabe, die ich in Processing umgesetzt habe.

 
ArrayList particles;
 
void setup() {
  size(640,480);
  particles = new ArrayList();
  smooth();
}
 
void draw() {
  particles.add(new Particle()); 
 
  background(255);
  for (int i = 0; i  100) {
    particles.remove(0); 
  }
}
 
class Particle {
 
  float x;
  float y;
  float xspeed;
  float yspeed;
 
  Particle() {
    x = mouseX;
    y = mouseY;
    xspeed = random(-1,1);
    yspeed = random(-2,0);
  }
 
  void run() {
    x = x + xspeed;
    y = y + yspeed;
  }
 
  void gravity() {
    yspeed += 0.1;
  }
 
  void display() {
    stroke(0);
    fill(0,75);
    line(x,y,10,10);
  }
}