Traveling Circle Answer

int x,y,radius;
int direction; // 0=right, 1=down, 2=left, 3=up
int step;
// boolean Running = false;

void setup() {
size(600,400);
radius = 30;
x = radius;
y = radius;
direction = 0;
step = 4;
}

void draw() {
background(50, 50, 200);

// if (!Running) return;

fill(200,50,50);
noStroke();
circle(x,y,2*radius);

if (direction == 0) {
if (x + radius + step> width) {
direction = 1;
y += step;
} else
x += step;
}
else if (direction == 1) {
if (y + radius + step > height) {
direction = 2;
x -= step;
}
else
y += step;
}
else if (direction == 2) {
if (x - radius - step< 0) {
direction = 3;
y -= step;
}
else
x -= step;
}
else {
if (y - radius - step < 0) {
direction = 0;
x += step;
}
else
y -= step;
}
}

/**
void mouseClicked() {
Running = !Running;
}
*/