Im not so good with Processing. But I’m trying to make the Memory game.
so far this is what I got: I can print 6 sets of cards. (12 cards in total) I have to match color with color.
But I have been thinking all day and still cant get it done. I don’t know what to do now. I dont know how to ‘flip’ the cards. I also don’t like the codes that I have been copying. Maybe u guys can help me a little bit.
final IntList randomRangeList = IntList.fromRange(1, 25);
int[] numbers;
int[] randomNumbers() {
randomRangeList.shuffle(this);
return expand(randomRangeList.values(), 24);
}
int[] abc = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24};
int waarde = 0;
void drawFrontOfCard() {
rectMode(CORNER);
textAlign(CENTER, CENTER);
aantalSetjes(setjes3);
int [][] tiles = new int[rijen][kolommen];
for (int k = 0; k < abc.length; k++) {
abc[k] = numbers[k];
}
tiles[0][0] = abc[0];
tiles[1][0] = abc[1];
tiles[2][0] = abc[2];
tiles[3][0] = abc[3];
tiles[0][1] = abc[4];
tiles[1][1] = abc[5];
tiles[2][1] = abc[6];
tiles[3][1] = abc[7];
tiles[0][2] = abc[8];
tiles[1][2] = abc[9];
tiles[2][2] = abc[10];
tiles[3][2] = abc[11];
tiles[0][3] = abc[12];
tiles[1][3] = abc[13];
tiles[2][3] = abc[14];
tiles[3][3] = abc[15];
tiles[0][4] = abc[16];
tiles[1][4] = abc[17];
tiles[2][4] = abc[18];
tiles[3][4] = abc[19];
tiles[0][5] = abc[20];
tiles[1][5] = abc[21];
tiles[2][5] = abc[22];
tiles[3][5] = abc[23];
//}
int xPos = 0;
int yPos =0;
for (int i =0; i<tiles.length; i++) {
for (int j =0; j<tiles[0].length; j++) {
xPos = 100 + i * (widthCard + margeCard);
yPos = 100 + j * (heightCard + margeCard);
fill(#00ffff);
textSize(30);
if (tiles[i][j] > 0) {
if (tiles[i][j] == 1 || tiles[i][j] == 2) {
waarde = tiles[i][j];
fill(#ff0000);
rect(xPos, yPos, widthCard, heightCard);
} else if (tiles[i][j] == 3 || tiles[i][j] == 4) {
waarde = tiles[i][j];
fill(#00ff00);
rect(xPos, yPos, widthCard, heightCard);
} else if (tiles[i][j] == 5 || tiles[i][j] == 6) {
waarde = tiles[i][j];
fill(#0000ff);
rect(xPos, yPos, widthCard, heightCard);
} else if (tiles[i][j] == 7 || tiles[i][j] == 8) {
waarde = tiles[i][j];
fill(#ffff00);
rect(xPos, yPos, widthCard, heightCard);
} else if (tiles[i][j] == 9 || tiles[i][j] == 10) {
waarde = tiles[i][j];
fill(#ff00ff);
rect(xPos, yPos, widthCard, heightCard);
} else if (tiles[i][j] == 11 || tiles[i][j] == 12) {
waarde = tiles[i][j];
fill(#00ffff);
rect(xPos, yPos, widthCard, heightCard);
} else if (tiles[i][j] == 13 || tiles[i][j] == 14) {
waarde = tiles[i][j];
fill(#c0c0c0);
rect(xPos, yPos, widthCard, heightCard);
} else if (tiles[i][j] == 15 || tiles[i][j] == 16) {
waarde = tiles[i][j];
fill(#000080);
rect(xPos, yPos, widthCard, heightCard);
} else if (tiles[i][j] == 17 || tiles[i][j] == 18) {
waarde = tiles[i][j];
fill(#008000);
rect(xPos, yPos, widthCard, heightCard);
} else if (tiles[i][j] == 19 || tiles[i][j] == 20) {
waarde = tiles[i][j];
fill(#008080);
rect(xPos, yPos, widthCard, heightCard);
} else if (tiles[i][j] == 21 || tiles[i][j] == 22) {
waarde = tiles[i][j];
fill(#800000);
rect(xPos, yPos, widthCard, heightCard);
} else if (tiles[i][j] == 23 || tiles[i][j] == 24) {
waarde = tiles[i][j];
fill(#543090);
rect(xPos, yPos, widthCard, heightCard);
}
}
}
}
}