public void setDirection(Direction direction) {
if(this.direction==Direction.LEFT&&direction!=Direction.RIGHT)
this.direction = direction;
else if(this.direction==Direction.UP&&direction!=Direction.DOWN)
this.direction = direction;
else if(this.direction==Direction.RIGHT&&direction!=Direction.LEFT)
this.direction = direction;
else if (this.direction==Direction.DOWN&&direction!=Direction.UP)
this.direction = direction;
}
package com.javarush.games.snake;
import com.javarush.engine.cell.*;
public class Apple extends GameObject{
private static final String APPLE_SIGN="\uD83C\uDF4E";
public boolean isAlive = true;
public Apple(int x, int y){
super(x, y);
}
public void draw(Game game){
game.setCellValueEx(x,y,Color.NONE,APPLE_SIGN,Color.ORANGE,75);
}
}