예제 #1
0
        public static void Move()
        {
            PointConsole tempPoint = BodyPoints.First();

            if (Direct == Direction.Up)
            {
                tempPoint = new PointConsole(tempPoint.X, tempPoint.Y - 1);
            }
            if (Direct == Direction.Down)
            {
                tempPoint = new PointConsole(tempPoint.X, tempPoint.Y + 1);
            }
            if (Direct == Direction.Left)
            {
                tempPoint = new PointConsole(tempPoint.X - 1, tempPoint.Y);
            }
            if (Direct == Direction.Right)
            {
                tempPoint = new PointConsole(tempPoint.X + 1, tempPoint.Y);
            }

            BodyPoints.Insert(0, tempPoint);
            new PointConsole(BodyPoints.Last().X, BodyPoints.Last().Y).DrawPoint(' ');
            BodyPoints.Remove(BodyPoints.Last());
            DrawSnake();
        }
예제 #2
0
 static void DrawSnake()
 {
     Console.ForegroundColor = ColorSnake;
     foreach (var p in BodyPoints)
     {
         Console.SetCursorPosition(p.X, p.Y);
         if (BodyPoints.First() == p)
         {
             Console.Write(HeadSymb);
         }
         else
         {
             Console.Write(BodySymb);
         }
     }
 }