int xLoc = 0; int xVelocity = 2; int rad = 20; int radVel = 2; void setup() { size(200,200); background(0); } void loop() { //framerate(10); //DRAWING CODE background(0); stroke(200); fill(100); ellipseMode(CENTER_DIAMETER); ellipse(xLoc,mouseY,rad,rad); //LOGIC xLoc = xLoc + xVelocity; if ( (xLoc >= width) || (xLoc <= 0) ) { //println(xVelocity); xVelocity = xVelocity * -1; rad = rad + radVel; if (rad > 25) { radVel = radVel * -1; } } }