示例#1
0
        static void Main(string[] args)
        {
            Game.Init();

            Timer T = new Timer(Move);

            T.Change(0, period);

            while (!Game.GameOver)
            {
                ConsoleKeyInfo button = Console.ReadKey();
                switch (button.Key)
                {
                case ConsoleKey.UpArrow:
                    dir = Direction.up;
                    break;

                case ConsoleKey.DownArrow:
                    dir = Direction.down;
                    break;

                case ConsoleKey.RightArrow:
                    dir = Direction.right;
                    break;

                case ConsoleKey.LeftArrow:
                    dir = Direction.left;
                    break;

                case ConsoleKey.Escape:
                    Game.GameOver = true;
                    break;

                case ConsoleKey.F1:
                    prevDir = dir;
                    Game.Save();
                    break;

                case ConsoleKey.F2:
                    dir = prevDir;
                    Game.Resume();
                    break;
                }
            }
            End();
        }