Вроде все верно, но валидатор отказывается принимать ответ
package com.javarush.games.snake;
import com.javarush.engine.cell.Color;
import com.javarush.engine.cell.Game;
import com.javarush.engine.cell.Key;
public class SnakeGame extends Game {
private Snake snake;
private int turnDelay;
public static void main(String[] args) {
new SnakeGame().initialize();
}
public static final int WIDTH = 15;
public static final int HEIGHT = 15;
@Override
public void initialize() {
setScreenSize(WIDTH, HEIGHT);
createGame();
}
private void createGame() {
turnDelay = 300;
setTurnTimer(turnDelay);
snake = new Snake(WIDTH / 2, HEIGHT / 2);
drawScene();
}
private void drawScene() {
for (int i = 0; i < WIDTH; i++) {
for (int j = 0; j < HEIGHT; j++) {
setCellValueEx(i, j, Color.DARKSEAGREEN, "");
}
}
snake.draw(this);
}
@Override
public void onTurn(int step) {
snake.move();
drawScene();
}
@Override
public void onKeyPress(Key key) {
if (key == Key.LEFT) {
snake.setDirection(Direction.LEFT);
} else if (key == Key.RIGHT) {
snake.setDirection(Direction.RIGHT);
} else if (key == Key.UP) {
snake.setDirection(Direction.UP);
} else if (key == Key.DOWN) {
snake.setDirection(Direction.DOWN);
}
}
}