xxxxxxxxxx
// only 1 "=" means we are telling the program that this is the state of the boolean when we
// begin the program. So here, the screen is blue, NOT YELLOW, when we run it.
boolean backgroundisYellow = false; // when program starts, background is not yellow
void setup(){
size (500, 500);
}
void draw (){
// Two "==" mean it's checking if this statement is true or false.
if (backgroundisYellow == true){ // Checks if background is yellow
background (255, 255, 0); // if that is true, then background is yellow
} else { // Checks if background is NOT Yellow
background (0, 255, 255); // changes it to blue
}
}
void mousePressed(){ // When mouse is pressed
if (backgroundisYellow == true){ // checks if background is yellow, i.e. if the boolean is true
backgroundisYellow = false; // if it is true, then when we press mouse change the boolean to false,
// i.e. make it blue now!
// without the "else" statement, the background will only change once. It wont switch back and forth
} else { // When we press mouse, change boolean to true
backgroundisYellow = true; // i.e. change it to yellow now!
}
}