示例#1
0
        public static void PlayStepByStepMessage(string[] input)
        {
            var sky      = Sky.BuildFrom(input);
            var minWidth = int.MaxValue;

            for (var i = 1;; i++)
            {
                sky.Tick();
                var(skyWidth, skyHeight) = sky.Dimensions;
                if (skyWidth < minWidth)
                {
                    minWidth = skyWidth;
                }

                //Console.Clear();
                //Console.SetCursorPosition(0, 0);
                if (i % 10000 == 0)
                {
                    Console.WriteLine(i);
                }
                if (minWidth > 500)
                {
                    continue;
                }

                Console.WriteLine($"After {i,4} second(s) - width={skyWidth,5} x height={skyHeight,5}  -  minWidth={minWidth,5}");

                // wait until sky has a reasonable size to attempt at drawing it
                if (skyWidth <= 200 && skyHeight <= 100)
                {
                    Console.Clear();
                    Console.SetCursorPosition(0, 0);
                    Console.WriteLine($"After {i,4} second(s) - width={skyWidth,5} x height={skyHeight,5}  -  minWidth={minWidth,5}");
                    Console.WriteLine(sky.Draw());
                    Console.WriteLine("press 'q' to exit or any key to continue...");
                    var c = Console.ReadKey();
                    if (c.KeyChar == 'q')
                    {
                        break;
                    }
                }
            }
        }