Игра работает по условию, на 180 повернуться не может, но валидатор ругается на последнее условие.
@Override
public void onKeyPress(Key key){
if (key == Key.LEFT && snake.getDirection() != Direction.RIGHT)
snake.setDirection(Direction.LEFT);
if (key == Key.RIGHT && snake.getDirection() != Direction.LEFT)
snake.setDirection(Direction.RIGHT);
if (key == Key.UP && snake.getDirection() != Direction.DOWN)
snake.setDirection(Direction.UP);
if (key == Key.DOWN && snake.getDirection() != Direction.UP)
snake.setDirection(Direction.DOWN);
}package com.javarush.games.snake;
import com.javarush.engine.cell.*;
public class Apple extends GameObject {
public boolean isAlive = true;
private static final String APPLE_SIGN = "\uD83C\uDF4E";
Apple(int x, int y) {
super(x, y);
}
public void draw(Game game){
game.setCellValueEx(x, y, Color.NONE, APPLE_SIGN, Color.RED, 75);
}
}