int narray[][] = new int[6][4];
int arraystate[][] = new int[6][4];
int arraynumber[][] = new int[6][4];
int clickmouse = 0;
int SHOWHUMBER = 1;
int HIDENUMBER = 2;
int var1[] = new int[3];
int var2[] = new int[3];
int varcounter = 0;
int[] data = new int[500];
int counterclick = 0;
void setup()
{
size(700,700);
background(122,122,122);
for (int i = 0;i < 6;i++)
{
for (int z = 0;z < 4;z++)
{
arraystate[i][z] = 0;
arraynumber[i][z] = 0;
rect(i*50,z*50,50,50);
}
}
int number = 0;
//формирование одинаковых пар чисел
for (int i = 0;i < 6; i++)
{
number++;
for (int j = 0;j < 4; j++)
{
if (i%2 == 0 && j%2 == 0)
{
narray[i][j] = number;
}
if (i%2+1!= 0 && j%2+1 != 0)
{
narray[i][j] = number;
}
}
}
for (int i = 0;i < 6; i++)
{
for (int j = 0;j < 4; j++)
{
int index1 = (int)random(0,6);
int index2 = (int)random(0,4);
//обмен значений
number = narray[i][j];
narray[i][j] = narray[index1][index2];
narray[index1][index2] = number;
}
}
int counter = 0;
for (int i = 0;i < 6; i++)
{
for (int j = 0;j < 4; j++)
{
data[counter] = narray[i][j];
counter++;
}
}
}
void draw(){
}
void mouseClicked() {
background(122,122,122);
for (int i = 0;i < 6;i++)
{
for (int z = 0;z < 4;z++)
{
fill(255.255,255);
rect(i*50,z*50,50,50);
}
}
int counter = 0;
for (int i = 0;i < 6;i++)
{
for (int z = 0;z < 4;z++)
{
counter++;
if (mouseX > i*50 && mouseX < i*50+50 && (mouseY > z*50 && mouseY<z*50+50) )
{
arraystate[i][z] = SHOWHUMBER;
var1[varcounter] = i;
var2[varcounter] = z;
varcounter++;
if (varcounter == 2) varcounter = 0;
}
if (arraystate[i][z]==SHOWHUMBER){
clickmouse++;
if (clickmouse == 3)
{
arraystate[var1[0]][var2[0]] = HIDENUMBER;
arraystate[var1[1]][var2[1]] = HIDENUMBER;
clickmouse = 0;
}
textSize(25);
fill(0,255,0);
text(narray[i][z],i*50+15, z*50+25);
}
}
}
}
|