xxxxxxxxxx
int x = 20; // for moving ellipse horizontally!
int y = 20; // for moving ellipse vertically!
void setup(){
size (400, 400);
}
void draw (){
// put background in *draw* if you want the ellipse to move across screen
// you would put it in setup if you want it to leave a trail behind it
background ( 255, 255, 0); // yellow!
// only the x co-ordinate moves
fill (255, 0, 0); // red
ellipse (x, 20, 30, 30); // moves horizontally (left to right)
// only the y co-ordinate moves
fill (0, 255, 0); // green
ellipse (20, y, 30, 30); // moves vertically (top to bottom)
// both the x and the y co-ordinates move
fill (0, 0, 255); // blue
ellipse (x, y, 30, 30); // moves diagonally (top left to bottom right)
// move the x coordinate +1 pixel (goes left)
x = x+1;
// move the y co-ordinate +1 pixel (goes down)
y = y+1;
}