int narray[][] = new int[6][4];
int arraystate[][] = new int[6][4];
int arraynumber[][] = new int[6][4];
int clickmouse = 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;
}
}
}
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) )
{
data[counterclick] = narray[i][z];
counterclick++;
arraystate[i][z] = 1;
clickmouse++;
if (clickmouse == 2) clickmouse = 0;
println(clickmouse);
}
if (arraystate[i][z]==1){
textSize(25);
fill(0,255,0);
text(narray[i][z],i*50+15, z*50+25);
}
}
}
}
|