Exemple #1
0
 public void RemoveSnakeBody()
 {
     for (int i = 0; i < SnakeBody.Count(); i++)
     {
         Console.SetCursorPosition(SnakeBodyY[i], SnakeBodyX[i]);
         Console.Write(" ");
     }
 }
Exemple #2
0
        public bool DetectBodyCollision()
        {
            for (int i = 0; i < SnakeBody.Count(); i++)
            {
                if (XPosition == SnakeBodyX[i] && YPosition == SnakeBodyY[i])
                {
                    return(false);
                }
            }

            return(true);
        }
Exemple #3
0
        public void DrawSnake()
        {
            Console.SetCursorPosition(GetPreviousYPosition(), GetPreviousXPosition());
            Console.Write(" ");

            Console.SetCursorPosition(GetYPosition(), GetXPosition());
            Console.Write(GetSnakeHead());

            for (int i = 0; i < PreviousBodyXPositions.Count(); i++)
            {
                Console.SetCursorPosition(PreviousBodyYPositions[i], PreviousBodyXPositions[i]);
                Console.Write(" ");
            }

            for (int i = 0; i < SnakeBody.Count(); i++)
            {
                Console.SetCursorPosition(SnakeBodyY[i], SnakeBodyX[i]);
                Console.Write(SnakeBody[i]);
            }
        }