How do i make it so the color of the box changes permanently?
in
Programming Questions
•
10 months ago
int boxradius = 25;
int timer = 0;
int timer2 = 0;
boolean change = false;
int Colors(){
return int(random(0,255));
}
color c = color (Colors(),Colors(),Colors());
color c2 = color (Colors(),Colors(),Colors());
int[] squareX = { 50,100,150,200,250,300,350,400,450,500 };
int[] squareY = { 50,100,150,200,250,300,350,400,450,500 };
void setup() {
size(500,500);
frameRate(60);
smooth();
noCursor();
rectMode(CENTER);
}
void draw()
{
background(c2);
Board();
}
void Board()
{
for (int i = 0; i < 9; i++) {
for (int j = 0; j < 9; j++) {
if (mouseX > squareX[i]-boxradius &&
mouseX < squareX[i]+boxradius &&
mouseY > squareY[j]-boxradius &&
mouseY < squareY[j]+boxradius){
fill(c);
}else{
fill(255);
}
rect(squareX[i],squareY[j],50,50);
}
}
}
1