Не пойму в чем проблема?
package com.javarush.games.snake;
import com.javarush.engine.cell.*;
public class SnakeGame extends Game {
public static final int WIDTH = 15;
public static final int HEIGHT = 15;
private Snake snake;
private int turnDelay;
private Apple apple;
@Override
public void initialize() {
setScreenSize(WIDTH, HEIGHT);
createGame();
}
private void createGame() {
snake = new Snake(WIDTH / 2, HEIGHT / 2);
createNewApple();
drawScene();
turnDelay = 300;
setTurnTimer(turnDelay);
}
private void drawScene() {
for (int x = 0; x < 15; x++) {
for (int y = 0; y < 15; y++) {
setCellValueEx(x, y, Color.DARKSEAGREEN, "");
}
}
snake.draw(this);
apple.draw(this);
}
@Override
public void onTurn(int turnDelay) {
snake.move(apple);
if (apple.isAlive == false) {
createNewApple();
}
drawScene();
}
@Override
public void onKeyPress(Key key) {
if (Key.LEFT == key) {
snake.setDirection(Direction.LEFT);
}
if (Key.RIGHT == key) {
snake.setDirection(Direction.RIGHT);
}
if (Key.UP == key) {
snake.setDirection(Direction.UP);
}
if (Key.DOWN == key) {
snake.setDirection(Direction.DOWN);
}
}
private void createNewApple() {
int x = getRandomNumber(WIDTH);
int y = getRandomNumber(HEIGHT);
apple = new Apple(x, y);
}
}