float x, y; // The current coordinates of the ball float r = 20; // ball radius float vx=1, vy=1; // ball velocity void setup() { size(400,400); smooth(); noStroke(); // print instructions println("x/X: de/increase x step size"); println("y/Y: de/increase y step size"); println("c: go to center of window"); x = width/2; y = height/2; // start at the center } void draw() { background(0); ellipse(x,y,2*r,2*r); // take a step x += vx; y += vy; // stay on screen x = constrain(x,0,width); y = constrain(y,0,height); } void keyPressed() { if (key=='x') vx--; else if (key=='X') vx++; else if (key=='y') vy--; else if (key=='Y') vy++; else if (key=='c') { x = width/2; y = height/2; } println("velocity: "+vx+","+vy); } // START NO NOTES // code used to capture screenshots void keyReleased() { if(key == '`' && !online) save("sketch.png"); }