Example #1
0
        private void CheckApple()
        {
            foreach (var apple in this.AppleList)
            {
                if (snake.Parts.First.Value.Position.Equals(apple.Position))
                {
                    ++score;
                    snake.Grow();
                    TheBoard.DrawBoard(); //  there is a problem with. When snake is going near bounds and eat apple on the bounds appear black "space"
                    TheBoard.WritePoints();
                    TheBoard.WriteLengthOfSnake(snake.Parts.Count);
                    ChangeFoodPosition(apple);
                }
            }

            foreach (var movingFood in this.movingFoodsList)
            {
                if (snake.Parts.First.Value.Position.Equals(movingFood.Position))
                {
                    score += 2;
                    snake.Grow();
                    TheBoard.DrawBoard();
                    TheBoard.WritePoints();
                    TheBoard.WriteLengthOfSnake(snake.Parts.Count);
                    ChangeFoodPosition(movingFood);
                }
            }
        }
Example #2
0
 public GameEngine()
 {
     TheBoard.DrawBoard();
     initializeSnake();
     initializeMovingObstacles();
     initializeObstacles();
     initializeFood();
     StartGame();
 }