Movement
Any place where you use a number in Processing, you can use a variable.
int x=20;
int y=30;
int w=15;
int h=40;
ellipse(x,y,w,h);
Adding the counting code creates animation
int x=0;
void setup()
{
size(500,300);
}
void draw()
{
background(0);
x=x+1;
ellipse(x,100,20,20);
}
Variations:
- Leave out the background command
- add different numbers to x instead of 1
- make the ellipse start at the right side and move to the left
- use x to replace different numbers in the ellipse command