We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I want to be able to cycle my colours indefinitely on mouse clicks, and I know that if I have three colours in total, so colourOne=0, colourTwo=1, colourThree=2, then I will need to make it so when the mouse is clicked at colourThree, i'll get the value 0. but I am not sure how to put that in my code.
boolean colourOne= false;
boolean colourTwo= false;
boolean colourThree= false;
void setup(){
size(500,500);
}
void draw(){
rect(100,100,50,50);
allColours();
}
void colourRed(){
background(255,0,0);
}
void colourGreen(){
background(0,255,0);
}
void colourBlue(){
background(0,0,255);
}
void allColours(){
if(colourOne){
colourRed();
if(colourTwo){
colourGreen();
if(colourThree){
colourBlue();
}
}
}
}
void mouseClicked(){
if(!colourOne){
colourOne=true;
}
else if(!colourTwo){
colourTwo=true;
}
else if(!colourThree){
colourThree=true;
}
}
Answers
https://Processing.org/reference/modulo.html
https://OpenProcessing.org/sketch/473642