int arrayrect[][] = new int[10][10];
int COUNTER = 0;
int COUNTER_2 = 0;
int EMPTY_CELL = 10;
int SELECT_CELL = 11;
int CELL_1 = 12;
int CELL_2 = 13;
void setup()
{
size(450,700);
background(122,122,122);
for (int i = 0; i < 9; i++)
{
for (int j = 0; j < 9; j++)
{
fill(255,255,255);
rect(i*50,j*50,50,50);
}
}
for (int i = 0;i <9; i++)
{
for (int q = 0;q <9; q++)
{
arrayrect[i][q] = EMPTY_CELL;
}
}
for (int i = 0;i <9; i++)
{
arrayrect[i][int(random(9))] = SELECT_CELL;
}
for (int i = 0; i < 9; i++)
{
for (int j = 0; j < 9; j++)
{
fill(255,255,255);
rect(i*50,j*50,50,50);
fill(int(random(255)), int(random(255)),int(random(255)));
if (arrayrect[i][j] == SELECT_CELL)
rect( i*50, j*50,50,50);
}
}
}
void draw()
{
background(122,122,122);
fill(0,0,0);
text("Сделано кликов мышью",0,500);
text(COUNTER,150,500);
if (COUNTER_2 == 9)
{
text("Все объекты найдены",0,550);
}
for (int i = 0; i < 9;i++){
for (int j = 0; j < 9; j++)
{
if (arrayrect[i][j] == CELL_1)
{
fill(0,0,0);
rect(i*50,j*50,50,50);
}
else
{
fill(255,255,255);
rect(i*50,j*50,50,50);
}
if (arrayrect[i][j] == CELL_2)
{
fill(255,0,0);
rect(i*50,j*50,50,50);
}
}
}
}
void mousePressed()
{
COUNTER++;
for (int i = 0; i < 9; i++)
{
for (int j = 0; j < 9; j++)
{
if (mouseX > i*50 && mouseX < i*50 + 50 && mouseY > j*50 && mouseY < j*50+50 )
{
if (arrayrect[i][j] == EMPTY_CELL)
{
arrayrect[i][j] = CELL_1;
fill(0,0,0);
rect( i*50, j*50,50,50);
}
if (arrayrect[i][j] == SELECT_CELL)
{
COUNTER_2++;
arrayrect[i][j] = CELL_2;
fill(255, 0, 0);
rect( i*50, j*50,50,50);
}
}
}
}
}
|