Exemple #1
0
        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;
        }
Exemple #2
0
 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
     };
 }
Exemple #3
0
 public void GenerateNewFood(Position position)
 {
     var food = new Food(position);
     this.Food = food;
 }