Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            Console.CursorVisible = false;
            Thread thread = new Thread(Game);

            thread.Start();

            while (!gameover)
            {
                ConsoleKeyInfo btn = Console.ReadKey();
                if (btn.Key == ConsoleKey.UpArrow)
                {
                    if (direction != 2)
                    {
                        direction = 1;
                    }
                }
                if (btn.Key == ConsoleKey.DownArrow)
                {
                    if (direction != 1)
                    {
                        direction = 2;
                    }
                }
                if (btn.Key == ConsoleKey.RightArrow)
                {
                    if (direction != 4)
                    {
                        direction = 3;
                    }
                }
                if (btn.Key == ConsoleKey.LeftArrow)
                {
                    if (direction != 3 && direction != 0)
                    {
                        direction = 4;
                    }
                }
                if (btn.Key == ConsoleKey.Escape)
                {
                    gameover = true;
                }

                if (btn.Key == ConsoleKey.Q)
                {
                    snake.Serialization();
                    food.Serialization();
                    wall.Serialization();

                    /* qm = map;
                     * ql = level;
                     * qcnt = cnt;
                     * qs = score;
                     * qd = direction;
                     * qspeed = speed;
                     * qsp = sp;*/
                }
                if (btn.Key == ConsoleKey.W)
                {
                    snake = snake.Deserialization();
                    food  = food.Deserialization();
                    wall  = wall.Deserialization();

                    Console.Clear();

                    /*map = qm;
                    *  level = ql;
                    *  cnt = qcnt;
                    *  score = qs;
                    *  direction = qd;
                    *  speed = qspeed;
                    *  sp = qsp;*/
                }
            }
        }