xxxxxxxxxx
boolean bgisyellow = false;
int rX, rY, rW, rH;
int x, y, w, h;
int speed = 5;
void setup () {
size(500, 500);
fill(#FFA00F); //orange
rX = width/4;
rY = height/4;
rW = 100;
rH = 100;
x = 25;
y = 175;
w = 50;
h = 50;
}
void draw () {
background(#03F6FC); //blue background
if (bgisyellow == true) {
background (#FCFC03);
}
fill(#E8A107);
stroke(255);
rect(rX, rY, rW, rH);
fill(#5DE802); //green
stroke(#E82507); //red
ellipse(x, y, w, h);
x = x + speed;
if ((x > 95) || (x < 25) ) {
speed = speed * -1;
}
}
void mousePressed () {
if ((mouseX < 225) && (mouseX > width/4)) {
if ((mouseY < 225) && (mouseY > height/4))
if (bgisyellow == true) {
bgisyellow = false;
} else {
bgisyellow = true;
}
}
}