Exemple #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();
        }
Exemple #2
0
        static void Main(string[] args)
        {
            //Image img = Image.FromFile("test.file");

            Console.BackgroundColor = ConsoleColor.Black;
            Console.ForegroundColor = ConsoleColor.White;

            Console.Clear();

            GMU gmu = new GMU(100, 40, 0, 0);

            MultiSplitScreenManager msc = new MultiSplitScreenManager(gmu.PlacePixels, 40, 100);


            FullScreenManager full = new FullScreenManager(40, 100, null);

            msc.AddScreen(full, new Rectangle(0, 0, 40, 100));

            FullScreenManager fs1 = new FullScreenManager(50, 40, null);
            FullScreenManager fs2 = new FullScreenManager(50, 40, null);



            full.App_DrawScreen(BasicProvider.getInked(4, 100, new PInfo().SetBg(ConsoleColor.Black).SetFg(ConsoleColor.White)), 0, 0, null);

            gmu.PrintFrame();

            full.App_DrawScreen(BasicProvider.TextToPInfo("Test", 20, 20, new PInfo().SetFg(ConsoleColor.White)), 3, 3, null);

            gmu.PrintFrame();

            Console.ForegroundColor = ConsoleColor.White;
            Console.WriteLine(Console.WindowWidth);
            Console.WriteLine(Console.WindowHeight);

            Console.WriteLine(Console.LargestWindowWidth);
            Console.WriteLine(Console.LargestWindowHeight);

            msc.AddScreen(fs1, new Rectangle(0, 0, 50, 40));
            msc.AddScreen(fs2, new Rectangle(50, 0, 50, 40));

            Console.ReadKey();
            gmu.PlacePixels(simpleSquare, 20, 8, null);

            fs1.App_DrawScreen(BasicProvider.getInked(48, 38, new PInfo(' ', ConsoleColor.White, ConsoleColor.Red)), 1, 1, null);
            fs2.App_DrawScreen(BasicProvider.getInked(48, 38, new PInfo(' ', ConsoleColor.White, ConsoleColor.Blue)), 1, 1, null);

            fs1.App_DrawScreen(simpleSquare, 1, 1, null);

            fs2.App_DrawScreen(BasicProvider.TextToPInfo("I try this new thing with text", 10, 10, new PInfo().SetFg(ConsoleColor.Black)), 3, 5, null);
            fs2.App_DrawScreen(BasicProvider.TextToPInfo("I try this new thing with text", 10, 10, new PInfo().SetFg(ConsoleColor.Red)), 3, 2, null);


            gmu.PrintFrame();

            Console.ReadLine();
        }
        static void Main(string[] args)
        {
            GMU gmu = new GMU(width + 5, height + 5, 1, 1);

            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));

            //screen.App_DrawScreen(BasicProvider.TextToPInfo("Hello World!", 7, 3, new PInfo().SetBg(ConsoleColor.Gray).SetFg(ConsoleColor.Green)),5,5,screen);



            // Camera and objects
            List <Geometry> geometries = new List <Geometry>();

            geometries.Add(new Geometry(new Vector3(1, 1, 5), ConsoleColor.Red));
            geometries.Add(new Geometry(new Vector3(3, 0, 2), ConsoleColor.Yellow));
            geometries.Add(new Geometry(new Vector3(-2, 1, 4), ConsoleColor.Green));

            Camera c = new Camera(new Vector3(0, 2, 0), new Vector3(0, 0, 1), height - 2, width - 2, 110, geometries);

            PInfo[,] image = c.RenderImage();

            screen.App_DrawScreen(image, 0, 0, null);

            gmu.PrintFrame();

            //Console.ReadLine();
            Debug.WriteLine("first frame");
            System.Threading.Thread.Sleep(5000);
            c.ViewDirection = new Vector3(1, 0, 1);
            Debug.WriteLine("Direction Change");
            System.Threading.Thread.Sleep(2000);

            PInfo[,] data = c.RenderImage();
            Debug.WriteLine("render");
            System.Threading.Thread.Sleep(2000);
            screen.App_DrawScreen(data, 0, 0, screen);
            Debug.WriteLine("Screen");
            System.Threading.Thread.Sleep(2000);
            gmu.PrintFrame();
            Debug.WriteLine("PrintFrame");



            Console.ReadLine();
        }
Exemple #4
0
        static void Main(string[] args)
        {
            Console.ReadLine();

            FastGMU gmu = new FastGMU(102, 62);

            gmu.PlacePixels(BasicProvider.getInked(102, 62, new PInfo().SetBg(ConsoleColor.DarkGray)), 0, 0, null);
            gmu.PrintFrame();
            gmu.PlacePixels(BasicProvider.getInked(100, 60, new PInfo().SetBg(ConsoleColor.Black).SetFg(ConsoleColor.White).SetC(' ')), 1, 1, null);
            gmu.PrintFrame();

            MultiSplitScreenManager SmallScreen = new MultiSplitScreenManager(gmu.PlacePixels, 102, 62);

            MultiSplitScreenManager splitScreen = new MultiSplitScreenManager(SmallScreen.App_DrawScreen, 100, 60, new PInfo().SetBg(ConsoleColor.Gray), new PInfo().SetBg(ConsoleColor.White).SetC(' '));

            SmallScreen.AddScreen(splitScreen, new System.Drawing.Rectangle(1, 1, 100, 60));

            WindowScreenManager Test = new WindowScreenManager(20, 30, splitScreen.App_DrawScreen, new PInfo().SetBg(ConsoleColor.Black).SetC(' '));

            WindowScreenManager Test2 = new WindowScreenManager(20, 30, splitScreen.App_DrawScreen, new PInfo().SetBg(ConsoleColor.Black).SetC(' '));

            splitScreen.AddScreen(Test, new System.Drawing.Rectangle(79, 5, 20, 30), 2);
            splitScreen.AddScreen(Test2, new System.Drawing.Rectangle(69, 8, 20, 30), 1);


            TextBox tb1 = new TextBox("Name", "Test text for some things", new PInfo().SetFg(ConsoleColor.White), 0, 0, Alignment.TopLeft, 20, 10);
            TextBox tb2 = new TextBox("try", "Another text", new PInfo().SetFg(ConsoleColor.Red).SetBg(ConsoleColor.DarkGray), 0, 0, Alignment.BottomLeft, 20, 10);

            List <TextBox> content = new List <TextBox>();

            content.Add(tb1);
            content.Add(tb2);

            WindowSheet sheet = new WindowSheet("Test", content);

            Test.LoadSheet(sheet);
            Test2.LoadSheet(sheet);
            Test2.GetTextBox("Name").Content = "This is another TestBox. How is this working?";

            splitScreen.Render();
            gmu.PrintFrame();
            Console.ReadKey(true);
            ConsoleKeyInfo info;

            int selected = 1;

            IRenderingApplication app = Test;

            while ((info = Console.ReadKey(true)).Key != ConsoleKey.Spacebar)
            {
                switch (info.Key)
                {
                case ConsoleKey.D1:
                    selected = 1;
                    app      = Test;
                    splitScreen.ChangeLayerOf(Test2, 1);
                    break;

                case ConsoleKey.D2:
                    selected = 2;
                    app      = Test2;
                    splitScreen.ChangeLayerOf(Test2, 3);
                    break;

                case ConsoleKey.LeftArrow:
                    splitScreen.TranslatePositionOf(app, new System.Drawing.Point(-1, 0));
                    break;

                case ConsoleKey.RightArrow:
                    splitScreen.TranslatePositionOf(app, new System.Drawing.Point(1, 0));
                    break;

                case ConsoleKey.DownArrow:
                    splitScreen.TranslatePositionOf(app, new System.Drawing.Point(0, 1));
                    break;

                case ConsoleKey.UpArrow:
                    splitScreen.TranslatePositionOf(app, new System.Drawing.Point(0, -1));
                    break;

                case ConsoleKey.Enter:
                    string input = Console.ReadLine();
                    Test2.GetTextBox("Name").Content = input;
                    break;

                default:
                    break;
                }
                splitScreen.Render();
                gmu.PrintFrame();
            }

            splitScreen.ChangeLayerOf(Test2, 3);
            splitScreen.Render();
            gmu.PrintFrame();
            Console.ReadKey();
            splitScreen.ChangeLayerOf(Test2, 1);
            splitScreen.Render();
            gmu.PrintFrame();
            Console.ReadKey();
            splitScreen.ChangeLayerOf(Test2, 3);
            splitScreen.Render();
            gmu.PrintFrame();
            Console.ReadKey();
            splitScreen.ChangeLayerOf(Test2, 1);
            splitScreen.Render();
            gmu.PrintFrame();



            Console.ReadKey();
        }
        static void Main(string[] args)
        {
            Console.InputEncoding  = Encoding.Unicode;
            Console.OutputEncoding = Encoding.Unicode;

            GMU gmu = new GMU(120, 40, 0, 0);

            gmu.PlacePixels(BasicProvider.getInked(120, 60, new PInfo().SetBg(ConsoleColor.Black)), 0, 0, null);
            gmu.PrintFrame();

            MultiSplitScreenManager Screen = new MultiSplitScreenManager(gmu.PlacePixels, 120, 60);



            WindowScreenManager p1Thing    = new WindowScreenManager(1, 4, Screen.App_DrawScreen, new PInfo().SetBg(ConsoleColor.Gray).SetC('\u2656').SetFg(ConsoleColor.Blue));
            WindowScreenManager p2Thing    = new WindowScreenManager(1, 4, Screen.App_DrawScreen, new PInfo().SetBg(ConsoleColor.Gray).SetC('\u2656').SetFg(ConsoleColor.Blue));
            WindowScreenManager background = new WindowScreenManager(120, 40, Screen.App_DrawScreen, new PInfo().SetBg(ConsoleColor.Black));

            WindowScreenManager bThing = new WindowScreenManager(1, 1, Screen.App_DrawScreen, new PInfo().SetBg(ConsoleColor.White));



            Screen.AddScreen(p1Thing, new Rectangle(1, 18, 1, 4), 1);
            Screen.AddScreen(p2Thing, new Rectangle(118, 18, 1, 4), 1);
            Screen.AddScreen(background, new Rectangle(0, 0, 120, 40), 0);

            bool running = true;


            Point Ball = new Point(40, 20);


            Thread thread = new Thread(() => {
                while (running)
                {
                    System.Threading.Thread.Sleep(10);

                    int p1Move = 0;
                    int p2Move = 0;
                    #region input handeling
                    if (Keyboard.IsKeyDown(Key.W))
                    {
                        p1Move += -1;
                    }
                    if (Keyboard.IsKeyDown(Key.S))
                    {
                        p1Move += 1;
                    }
                    if (Keyboard.IsKeyDown(Key.Up))
                    {
                        p2Move += -1;
                    }
                    if (Keyboard.IsKeyDown(Key.Down))
                    {
                        p2Move += 1;
                    }
                    if (Keyboard.IsKeyDown(Key.Escape))
                    {
                        running = false;
                    }
                    if (Keyboard.IsKeyDown(Key.Space))
                    {
                    }
                    #endregion

                    #region movement

                    #endregion
                    #region score

                    #endregion
                    #region Time

                    #endregion

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

            thread.SetApartmentState(ApartmentState.STA); //Set the thread to STA
            thread.Start();
            thread.Join();



            Screen.Render();
            gmu.PrintFrame();

            Console.ReadKey();
        }
Exemple #6
0
        public static void StartGMU()
        {
            FastGMU gmu = new FastGMU(width, height);
            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();

            bool stop  = false;
            bool sneak = false;

            doom.PlayerHeight = 1;
            Stopwatch watch = new Stopwatch();

            while (!stop)
            {
                watch.Start();
                time += 0.1;

                double currRotation = Math.Atan2(doom.Player.y_2 - doom.Player.y_1, doom.Player.x_2 - doom.Player.x_1);



                if (Keyboard.IsKeyDown(Key.C))
                {
                    if (sneak)
                    {
                        doom.PlayerHeight = 1;
                        sneak             = false;
                    }
                    else
                    {
                        doom.PlayerHeight = 0.5;
                        sneak             = true;
                    }
                }

                if (Keyboard.IsKeyDown(Key.A))
                {
                    MoveLeft(doom);
                }

                if (Keyboard.IsKeyDown(Key.S))
                {
                    MoveBack(doom);
                }

                if (Keyboard.IsKeyDown(Key.D))
                {
                    MoveRight(doom);
                }

                if (Keyboard.IsKeyDown(Key.W))
                {
                    MoveFront(doom);
                }

                if (Keyboard.IsKeyDown(Key.Right))
                {
                    doom.Player.x_2 = doom.Player.x_1 + Math.Cos(currRotation + rotation);
                    doom.Player.y_2 = doom.Player.y_1 + Math.Sin(currRotation + rotation);
                }

                if (Keyboard.IsKeyDown(Key.Left))
                {
                    doom.Player.x_2 = doom.Player.x_1 + Math.Cos(currRotation - rotation);
                    doom.Player.y_2 = doom.Player.y_1 + Math.Sin(currRotation - rotation);
                }


                doom.PlayerHeight = (sneak ? 1 : 0.5) + Math.Sin(time) * 0.1;
                //Console.Clear();
                doom.Render();
                watch.Stop();
                gmu.PlacePixels(
                    BasicProvider.TextToPInfo((1d / ((double)watch.ElapsedMilliseconds / 1000)).ToString("#.000") + " FPS", 10, 1,
                                              new PInfo().SetBg(ConsoleColor.Black).SetFg(ConsoleColor.White)), 0, 0, null);
                watch.Restart();
                gmu.PrintFrame();
                System.Threading.Thread.Sleep(1);
            }


            //Console.ReadKey(true);
        }
Exemple #7
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);
        }
Exemple #8
0
        public static void RunInConsole()
        {
            FastGMU gmu = new FastGMU(width + 2, height + 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());

            ConsoleKeyInfo input;

            double MoveDistance = 0.2;
            double rotateRad    = Vector3.DegToRad(5);

            bool running = true;


            while (running)
            {
                //System.Threading.Thread.Sleep(20);

                if (Keyboard.IsKeyDown(Key.Escape))
                {
                    running = false;
                }

                if (Keyboard.IsKeyDown(Key.A))
                {
                    c.Position = c.Position + ((new Vector3(-c.ViewDirection.Z, 0, c.ViewDirection.X).AsNormalized()) * MoveDistance);
                }

                if (Keyboard.IsKeyDown(Key.S))
                {
                    c.Position = c.Position + ((new Vector3(c.ViewDirection.X, 0, c.ViewDirection.Z).AsNormalized()) * -MoveDistance);
                }

                if (Keyboard.IsKeyDown(Key.D))
                {
                    c.Position = c.Position + ((new Vector3(c.ViewDirection.Z, 0, -c.ViewDirection.X).AsNormalized()) * MoveDistance);
                }

                if (Keyboard.IsKeyDown(Key.W))
                {
                    c.Position = c.Position + ((new Vector3(c.ViewDirection.X, 0, c.ViewDirection.Z).AsNormalized()) * MoveDistance);
                }

                if (Keyboard.IsKeyDown(Key.Space))
                {
                    c.Position = c.Position + (new Vector3(0, 1, 0) * MoveDistance);
                }


                if (Keyboard.IsKeyDown(Key.C))
                {
                    c.Position = c.Position + (new Vector3(0, -1, 0) * MoveDistance);
                }

                if (Keyboard.IsKeyDown(Key.Left))
                {
                    c.ViewDirection = c.ViewDirection.RotateY(-rotateRad);
                }

                if (Keyboard.IsKeyDown(Key.Down))
                {
                    double currAngle = c.ViewDirection.Angle.Y;
                    double target    = currAngle + rotateRad;
                    if (target < Math.PI)
                    {
                        // we can change the angle

                        double realAngle = Math.Abs(target - (Math.PI / 2));

                        double realHeight = Math.Tan(realAngle);
                        double corrected  = realHeight * Math.Sqrt(c.ViewDirection.X * c.ViewDirection.X + c.ViewDirection.Z * c.ViewDirection.Z);

                        c.ViewDirection.Y = corrected;

                        if (target > Math.PI / 2)
                        {
                            // negative
                            c.ViewDirection.Y = c.ViewDirection.Y * -1;
                        }
                    }
                }


                if (Keyboard.IsKeyDown(Key.Right))
                {
                    c.ViewDirection = c.ViewDirection.RotateY(rotateRad);
                }

                if (Keyboard.IsKeyDown(Key.Up))
                {
                    double currAngleI = c.ViewDirection.Angle.Y;
                    double targetI    = currAngleI - rotateRad;
                    if (targetI < Math.PI)
                    {
                        // we can change the angle

                        double realAngle = Math.Abs(targetI - (Math.PI / 2));

                        double realHeight = Math.Tan(realAngle);
                        double corrected  = realHeight * Math.Sqrt(c.ViewDirection.X * c.ViewDirection.X + c.ViewDirection.Z * c.ViewDirection.Z);

                        c.ViewDirection.Y = corrected;

                        if (targetI > Math.PI / 2)
                        {
                            // negative
                            c.ViewDirection.Y = c.ViewDirection.Y * -1;
                        }
                    }
                }

                //Debug.WriteLine("before render");
                screen.App_DrawScreen(c.RenderImage(), 0, 0, null);
                //Debug.WriteLine("After render");
                gmu.PrintFrame();
            }
        }