public GameEngine() { this.Setup(); this.speed = InitialSpeed; this.newGame = new Game(new Snake(), new Food(this.GetRandomPosition())); this.snake = this.newGame.Snake; this.food = this.newGame.Food; }
public Game(Snake snake, Food food) { this.Snake = snake; this.Food = food; this.Points = 0; this.direction = Direction.Right; this.directions = new Position[] { new Position(0, 1), // right new Position(0, -1), // left new Position(1, 0), // down new Position(-1, 0), // up }; }
public void GenerateNewFood(Position position) { var food = new Food(position); this.Food = food; }