예제 #1
0
파일: Program.cs 프로젝트: fkribs/Snake
        static async Task Run(int frameWait)
        {
            var ThePlayer = new Player(new System.Drawing.Point(25, 25));

            TheBoard  = new Board((int)(Console.WindowHeight * .9), (int)(Console.WindowWidth * .9), ThePlayer);
            FrameWait = frameWait;
            do
            {
                while (!Console.KeyAvailable)
                {
                    await Delay();

                    try
                    {
                        await ProcessBoardState();
                    }
                    catch (EndOfGameException e)
                    {
                        await WriteResults(e);
                    }
                    await UpdateBoard();
                }
            } while (!GetUserInput());
            try
            {
                TheBoard.EndGame("Escape key pressed!");
            }
            catch (EndOfGameException e)
            {
                await WriteResults(e);
            }
        }