Changing Speed

The amount you add to x every frame controls speed. You can use an if statement to change the speed halfway across the screen.
int x=0; void setup() { size(500,300); } void draw() { background(0); if (x > 250) { x=x+4; } else { x=x+1; } ellipse(x,100,20,20); }
Since any number in Processing can be replaced with a variable, speed can be too.
int x=0; int speed=1; void setup() { size(500,300); } void draw() { background(0); if (x>250) { speed=4; } x=x+speed; if (x > 500) { x=0; } ellipse(x,100,20,20); }