Кто не будь знает что тут не так
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];
@Override
public void initialize() {
setScreenSize(SIDE, SIDE);
createGame();
drawScene();
}
private void createGame() {
createNewNumber();
createNewNumber();
}
private void drawScene() {
for (int i = 0; i < SIDE; i++) {
for (int j = 0; j < SIDE; j++) {
setCellColoredNumber(i, j, gameField[i][j]);
}
}
}
private void createNewNumber() {
int x, y;
do {
x = getRandomNumber(SIDE);
y = getRandomNumber(SIDE);
} while (gameField[x][y] != 0);
if (getRandomNumber(10) == 9)
gameField[x][y] = 4;
else gameField[x][y] = 2;
}
private Color getColorByValue(int value) {
Color color = null;
if (value == 0) color = Color.RED;
if (value == 2) color = Color.AQUA;
if (value == 4) color = Color.BLUE;
if (value == 8) color = Color.SILVER;
if (value == 16) color = Color.ROSYBROWN;
if (value == 32) color = Color.AQUAMARINE;
if (value == 64) color = Color.YELLOW;
if (value == 128) color = Color.DIMGRAY;
if (value == 256) color = Color.LAVENDER;
if (value == 512) color = Color.LIGHTSTEELBLUE;
if (value == 1024) color = Color.WHITE;
if (value == 2048) color = Color.GRAY;
return color;
}
private void setCellColoredNumber(int x, int y, int value) {
if (value != 0) {
setCellValueEx(y, x, getColorByValue(value), Integer.toString(value));
// System.out.print(Integer.toString(value) + " ");
// System.out.println(x + " " + y);
} else {
setCellValueEx(y, x, getColorByValue(value), "");
// System.out.print(Integer.toString(value) + " ");
// System.out.println(x + " " + y);
}
}
}