// Drei bunte Bälle bewegen sich Ball ball1, ball2, ball3; void setup() { size(200,200); ball1 = new Ball(#ff0000); ball2 = new Ball(#00ff00); ball3 = new Ball(#0000ff); frameRate(30); smooth(); background(0);} void draw() { fill(0,4); rect(0,0,width,height); ball1.move(); ball2.move(); ball3.move(); ball1.paint(); ball2.paint(); ball3.paint(); } //////////////////////////////////////////////////////////// // class Ball { float x,y; // Ort float vx,vy; // Geschwindigkeit float r; // Radius int col; // Farbe Ball(int farbe) { r = 30; col = farbe; x = random(2*r,width-2*r); y = random(2*r,height-2*r); vx = random(-4,4); vy = random(-4,4); ellipseMode(RADIUS); paint(); } // das Ballobjekt darstellen void paint() { fill(col); noStroke(); ellipse(x,y,r,r); if (x>=r && xr && y=width-r) x -= width; if (y<0-r) y += height; if (y>=height-r) y -= height; } } // ////////////////////////////////////////////////////////////