float rot,x,y; void setup() { size(400,400); ellipseMode(CENTER_DIAMETER); rectMode(CENTER_DIAMETER); } void loop() { background(100,0,0); x+=random(-5,5); y+=random(-5,5); if(x<0) x=width; else if(x>width) x=0; if(y<0) y=height; else if(y>height) y=0; fill(255); noStroke(); push(); translate(x,y); rot+=radians(3); rotate(rot); rect(20,0, 20,20); pop(); }