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

            return(true);
        }
示例#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]);
            }
        }