Пример #1
0
        private void ClearTheScreen()
        {
            //Clear the tail
            for (int i = 0; i < snake.Tail.Count; i++)
            {
                CanvasPosition tailPosition = snake.Tail[i];
                ShowEmptyArenaPosition(tailPosition.RowPosition, tailPosition.ColumnPosition, tailPosition.Paint);
            }

            //Clear the head
            ShowEmptyArenaPosition(snake.HeadPositionOld.RowPosition, snake.HeadPositionOld.ColumnPosition, snake.HeadPosition.Paint);

            //Clear the food(s)
            for (int i = 0; i < foods.FoodPositions.Count; i++)
            {
                CanvasPosition foodPosition = foods.FoodPositions[i];
                ShowEmptyArenaPosition(foodPosition.RowPosition, foodPosition.ColumnPosition, foodPosition.Paint);
            }

            // Reset the displays
            playTime = TimeSpan.Zero;
            View.LabelPlayTime.Content       = $"{playTime.Minutes:00}:{playTime.Seconds:00}";
            View.NumberOfMealsTextBlock.Text = "0";

            // Set the snake to null
            snake = null;
        }
Пример #2
0
 public Snake(int rowPosition, int columnPosition)
 {
     HeadPosition    = new CanvasPosition(rowPosition, columnPosition, null);
     HeadPositionOld = new CanvasPosition(rowPosition, columnPosition, null);
     HeadDirection   = SnakeHeadDirectionEnum.InPlace;
     Length          = 6;
     Tail            = new List <CanvasPosition>();
     HeadPosition.ArenaPositionChanged += HeadPositionChanged;
 }