Processing Forum
int[] button = new int[10];
color[] c;
void setup()
{
size(600,400);
button = new int[10];
c = new color[5];
for (int i = 0; i < 10; i++)
{
button[i] = (int)random(5);
}
c[0] = color(255,0,0);
c[1] = color(200,100,20);
c[2] = color(210,200,40);
c[3] = color(50,250,90);
c[4] = color(0,0,255);
}
void draw()
{
for (int i = 0; i < 10; i++)
{
fill(c[ button[i] ]);
rect(i*width/10,height/2-50,width/10,100);
}
}
void mousePressed()
{
int x = mouseX*10/width;
if ((mouseY > height/2-50) && (mouseY < height/2+50))
{
button[x] = (button[x]+1);
if (button[x] > 4)
button[x] = 0;
}
}
int x = 5;
void draw()
{
changeX();
print(x);
}
void changeX()
{
int x = 7;
}