Hi All, I am very new in processing and I am trying to use an array to change the color of my background color by clicking with the mouse to use numbers from 0 to 4. This seems not really working on my sketch, any suggestion? Thanks!
color [] colors = new color[4];
int total=0;
void setup() {
size(500, 500);
colors[0] = color(0, 177, 235);
colors[1] = color(254, 199, 0);
colors[2] = color(232, 42, 5);
colors[3] = color(162, 198, 23);
for (int i=0; i<colors.length; i++) {
background(colors[int(total)]);
}
}
void draw() {
if (mousePressed == true) {
background(colors[int(total+1)]);
}
}