示例#1
0
        static void Main(string[] args)
        {
            snake.FinalWrite();
            name = Console.ReadLine();
            Console.Clear();
            Console.CursorVisible = false;
            food.SetRandomPosition(wall, snake);
            food.Draw();
            Thread thread = new Thread(Func);

            thread.Start();
            while (true)
            {
                if (k == 1)
                {
                    Console.ReadKey();
                    return;
                }
                ConsoleKeyInfo pk = Console.ReadKey();
                if (pk.Key == ConsoleKey.S)
                {
                    snake.A();
                    wall.A();
                    food.A();
                }
                if (pk.Key == ConsoleKey.V)
                {
                    Console.Clear();

                    snake = snake.B();
                    wall  = wall.B();
                    food  = food.B();
                }
                if (pk.Key == ConsoleKey.UpArrow)
                {
                    direction = 2;
                }
                if (pk.Key == ConsoleKey.DownArrow)
                {
                    direction = 1;
                }
                if (pk.Key == ConsoleKey.LeftArrow)
                {
                    direction = 4;
                }
                if (pk.Key == ConsoleKey.RightArrow)
                {
                    direction = 3;
                }
            }
        }