Processing Forum
int x = 300;
int y = 300;
int xspeed = -3;
int yspeed = -3;
void setup(){
size(600,400);
}
void draw(){
background(0);
ellipse(x, y, 20, 30);
x = x + xspeed;
if ( x == 0){
xspeed = 3;
}
if ( x > width){
xspeed = -3;
}
y = y + yspeed;
if ( y < 0){
yspeed = 3;
}
if ( y > height){
yspeed = -3;
}
}