// Diesen Wert ändern, um die Anzahl der Bälle anzupassen. int anzahl = 20; float x[] = new float[anzahl]; float y[] = new float[anzahl]; float vx[] = new float[anzahl]; float vy[] = new float[anzahl]; void setup() { size(400, 400); fill(255); smooth(); noStroke(); // Die Arrays aller Bälle werden initialisiert for (int i = 0; i < anzahl; i++) { x[i] = random(height); y[i] = random(width); vx[i] = random(-4, 4); vy[i] = random(-4, 4); } } void draw() { background(0); for (int i = 0; i < anzahl; i++) { // Ball wird gezeichnet, ellipse(x[i], y[i], 20, 20); // bewegt .. x[i] = x[i] + vx[i]; // und Kollisionen geprüft. if (x[i] > width || x[i] < 0) { vx[i] = - vx[i]; } y[i] = y[i] + vy[i]; if (y[i] > height || y[i] < 0) { vy[i] = - vy[i]; } } }