示例#1
0
        public static void RunInForms()
        {
            GMUF gmu = new GMUF(height + 2, width + 2);


            MultiSplitScreenManager mssm   = new MultiSplitScreenManager(gmu.PlacePixels, width, height);
            FullScreenManager       screen = new FullScreenManager(width - 2, height - 2, null);

            mssm.AddScreen(screen, new System.Drawing.Rectangle(1, 1, width - 2, height - 2));
            gmu.PrintFrame();

            Camera c = GetCamera(GetGeometry());

            NotAConsoleWindow w = new NotAConsoleWindow();

            w.IdleHandle = () => OnIdleHandle(c, screen, gmu);
            Thread t = new Thread(() =>
            {
                Application.EnableVisualStyles();
                Application.Run(w);
            });

            (gmu).SetRederingForm(w);
            t.SetApartmentState(ApartmentState.STA);

            t.Start();
            Console.WriteLine("Running In forms");

            t.Join();
        }
示例#2
0
        public static void StartGMUF()
        {
            GMUF gmu            = new GMUF(height, width);
            NotAConsoleWindow w = new NotAConsoleWindow();

            Task t = new Task(() =>
            {
                Application.EnableVisualStyles();
                Application.Run(w);
            });

            (gmu as GMUF).SetRederingForm(w);

            t.Start();



            MultiSplitScreenManager sm = new MultiSplitScreenManager(gmu.PlacePixels, height, width);
            // use this for rendering
            FullScreenManager rs = new FullScreenManager(width - 2, height - 2, null);

            DoomScreenManager doom = new DoomScreenManager(null, width - 2, height - 2);

            sm.AddScreen(doom, new System.Drawing.Rectangle(1, 1, width - 2, height - 2));

            doom.Render();
            gmu.PrintFrame();


            ConsoleKey input;
            bool       sneak = false;

            while ((input = Console.ReadKey(true).Key) != ConsoleKey.Spacebar)
            {
                double currRotation = Math.Atan2(doom.Player.y_2 - doom.Player.y_1, doom.Player.x_2 - doom.Player.x_1);
                switch (input)
                {
                case ConsoleKey.C:
                    if (sneak)
                    {
                        doom.PlayerHeight = 1;
                        sneak             = false;
                    }
                    else
                    {
                        doom.PlayerHeight = 0.5;
                        sneak             = true;
                    }
                    break;

                case ConsoleKey.A:
                    MoveLeft(doom);
                    break;

                case ConsoleKey.S:
                    MoveBack(doom);
                    break;

                case ConsoleKey.D:
                    MoveRight(doom);
                    break;

                case ConsoleKey.W:
                    MoveFront(doom);
                    break;

                case ConsoleKey.RightArrow:
                    doom.Player.x_2 = doom.Player.x_1 + Math.Cos(currRotation + rotation);
                    doom.Player.y_2 = doom.Player.y_1 + Math.Sin(currRotation + rotation);
                    break;

                case ConsoleKey.LeftArrow:
                    doom.Player.x_2 = doom.Player.x_1 + Math.Cos(currRotation - rotation);
                    doom.Player.y_2 = doom.Player.y_1 + Math.Sin(currRotation - rotation);
                    break;

                default:
                    break;
                }
                //Console.Clear();

                doom.Render();
                gmu.PrintFrame();
            }


            //Console.ReadKey(true);
        }