Esempio n. 1
0
        static void Main(string[] args)
        {
            snake.RecordWrite();
            username = 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.F1();
                    wall.F1();
                    food.F1();
                    //thread.Suspend();
                }
                if (pk.Key == ConsoleKey.V)
                {
                    Console.Clear();
                    //thread.Resume();
                    snake = snake.F2();
                    wall  = wall.F2();
                    food  = food.F2();
                }
                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;
                }
            }
        }