int circle =0; int speed =5; void setup() { size(400, 600); } void draw() { background(0); //change x by speed circle = circle + speed; //if we have reached the reverse speed if ((circle > 400) || (circle < 0)) { speed = speed * -1; } // display a circle fill(150); stroke(0); fill(0, 0, 255); //-- rect(60, 100, 30, 60); noStroke(); triangle( 60,100, 192,100, 230,400 ); triangle( 188,100, 230,400, 360, 400 ); fill(255,0,0); beginShape(); vertex(60,300); vertex(90, 300); vertex(160, 500); vertex(130, 500); endShape(CLOSE); fill(255, 0, 100); ellipse(circle, 500, 35, 35); fill(255, 255, 0); ellipse(mouseX/2, mouseY/2, 150, 100); }