private void DebugUserControl_OnLoaded(object sender, RoutedEventArgs e)
        {
            InputProvider = new WPFInputProvider();
            this.gameLoop = new WPFGameLoop(InputProvider, this.txt, this.img, (int)(img.Width / 80));

            var text = "sokoban";

            switch (text)
            {
            case "sample":
                gameLoop.Scene = new SampleScene(gameLoop);
                gameLoop.Init();
                break;

            case "sokoban":
                // Init, so that we get the renderer
                gameLoop.Init();

                var bridgeSokobanPixelToConsolePixel = new BridgeSokobanPixelToConsolePixel(gameLoop.Renderer);

                var host = new BridgeGameLoop <ConsolePixel, SokobanPixel>(gameLoop, bridgeSokobanPixelToConsolePixel);
                host.Inner = new SokoSolveMasterGameLoop(host);

                host.Init();


                gameLoop.Scene = host;

                break;

            case "tetris":
                var tetris = new MasterGameLoop(gameLoop);
                gameLoop.Scene = tetris;
                gameLoop.Init();
                break;
            }


            gameLoop.Start();
        }
Beispiel #2
0
        public static void Run()
        {
            if (true)
            {
                System.Console.CursorVisible  = false;
                System.Console.OutputEncoding = Encoding.Unicode;

                var scale     = 1.5;
                var charScale = 3;

                // Setup: Display
                //DirectConsole.MaximizeWindow();
                var cons = DirectConsole.Setup(
                    (int)(80 * scale),
                    (int)(25 * scale),
                    7 * charScale,
                    10 * charScale,
                    "Consolas");

                var renderer = new ConsoleRendererCHAR_INFO(cons);
                var bridge   = new BridgeSokobanPixelToCHAR_INFO(renderer);

                // Setup: Input
                var input = new InputProvider()
                {
                    IsMouseEnabled = true
                };

                using (var consoleLoop = new ConsoleGameLoop <SokobanPixel>(input, bridge))
                {
                    using (var master = new SokoSolveMasterGameLoop(consoleLoop))
                    {
                        consoleLoop.Scene = master;
                        consoleLoop.Init();
                        consoleLoop.Start();
                    }
                }
            }
            else
            {
                System.Console.SetBufferSize(120, 60);
                System.Console.SetWindowSize(120, 60);
                var bridge = new BridgeSokobanPixelToConsolePixel(new ConsolePixelRenderer(BasicDirectConsole.Singleton));

                // Setup: Input
                var input = new InputProvider()
                {
                    IsMouseEnabled = true
                };

                using (var consoleLoop = new ConsoleGameLoop <SokobanPixel>(input, bridge))
                {
                    consoleLoop.SetGoalFramesPerSecond(5);
                    using (var master = new SokoSolveMasterGameLoop(consoleLoop))
                    {
                        consoleLoop.Scene = master;
                        consoleLoop.Init();
                        consoleLoop.Start();
                    }
                }
            }
        }