xxxxxxxxxx
float circleY;
float circleX;
float rad = 15;
float xspeed = 3;
float yspeed = 3.2;
int xdirection = 1;
int ydirection = 1;
void setup() {
frameRate(300);
ellipseMode(RADIUS);
size(800,550);
circleY = width/2;
circleX = height/2;
noStroke();
}
void draw() {
fill(circleX / 3, circleY * 0.8, 122 );
background(circleY * 0.8, circleX / 3, 200);
circleX = circleX + (xspeed * xdirection);
circleY = circleY + (yspeed * ydirection);
//bounce back on left and right corners
if (circleX < rad || circleX > width - rad) {
xdirection *= -1;
}
//bounce back on bottom and top corner
if (circleY > height - rad || circleY < rad) {
ydirection *= -1;
}
strokeWeight(6);
stroke(255);
ellipse(circleX, circleY, rad, rad);
}