Не могу понять почему не проходит, в рекомендациях написано сменить в gameField[x][y] на [y][x], не понимаю правда зачем но и так не проходит.
package com.javarush.games.game2048;
import com.javarush.engine.cell.*;
public class Game2048 extends Game{
private static final int SIDE = 4;
private int[][] gameField = new int[SIDE][SIDE];
private void createGame(){
createNewNumber();
createNewNumber();
}
private void drawScene(){
for(int a = 0; a < SIDE; a++)
for(int b = 0; b < SIDE; b++)
setCellColoredNumber(a, b, gameField[a][b]);
}
private void createNewNumber(){
int x;
if(getRandomNumber(10) == 9)
x = 4;
else x = 2;
while(true){
int a = getRandomNumber(SIDE);
int b = getRandomNumber(SIDE);
if(gameField[a][b] == 0){
gameField[a][b] = x;
break;
}
}
}
private Color getColorByValue(int value){
Color sCol = Color.WHITE;
if(value == 2)sCol = Color.AQUA;
if(value == 4)sCol = Color.AQUAMARINE;
if(value == 8)sCol = Color.DARKBLUE;
if(value == 16)sCol = Color.ALICEBLUE;
if(value == 32)sCol = Color.DARKCYAN;
if(value == 64)sCol = Color.DARKGOLDENROD;
if(value == 128)sCol = Color.DARKGRAY;
if(value == 256)sCol = Color.DARKGREEN;
if(value == 512)sCol = Color.DARKKHAKI;
if(value == 1024)sCol = Color.DARKMAGENTA;
if(value == 2048)sCol = Color.DARKOLIVEGREEN;
return sCol;
}
private void setCellColoredNumber(int x, int y, int value){
if(value == 0)setCellValueEx(x, y, getColorByValue(value), "");;
setCellValueEx(x, y, getColorByValue(value), "" + value);
}
@java.lang.Override
public void initialize() {
setScreenSize(SIDE, SIDE);
createGame();
drawScene();
}
}