Example #1
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();
        }
Example #2
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();
            }
        }
Example #3
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);
        }
Example #4
0
        static void Main(string[] args)
        {
            Console.ReadLine();
            Stopwatch stop = new Stopwatch();

            DirectConsoleAccess d   = new DirectConsoleAccess(90, 90, 1, 1);
            FastGMU             gmu = new FastGMU(90, 90);

            Console.ReadLine();
            stop.Start();

            //d.TestOutput();
            //d.TestPInfo();

            PInfo[,] data = new PInfo[90, 90];
            data.Populate(new PInfo().SetC('A').SetBg(ConsoleColor.Black).SetFg(ConsoleColor.White));
            d.PrintBuffer(data);


            stop.Stop();
            Console.WriteLine((double)stop.ElapsedMilliseconds / 1000);
            Console.WriteLine("-------------");

            Console.ReadLine();
            ClassicDebugger debugger = new ClassicDebugger();

            Holder <int> x     = new Holder <int>("X", 0, 10);
            Holder <int> y     = new Holder <int>("Y", 0, 10);
            Holder <int> index = new Holder <int>("i", 0, 10);
            Holder <int> left  = new Holder <int>("left", 0, 10);
            Holder <int> top   = new Holder <int>("top", 0, 10);
            Holder <int> w     = new Holder <int>("with", 0, 10);
            Holder <int> h     = new Holder <int>("height", 0, 10);

            HolderString s = new HolderString("---");

            debugger.Watcher.Add(x);
            debugger.Watcher.Add(y);
            debugger.Watcher.Add(index);
            debugger.Watcher.Add(left);
            debugger.Watcher.Add(top);
            debugger.Watcher.Add(w);
            debugger.Watcher.Add(h);
            debugger.Watcher.Add(s);

            debugger.UpdateTime = 200;
            debugger.Activate();

            //Console.SetWindowPosition(10, 10);



            while (!Console.KeyAvailable)
            {
                //index.value++;
                var i = MouseInput.GetMousePosition();
                x.value = i.X;
                y.value = i.Y;

                var pos = MouseInput.GetMouseConsolePosition();

                left.value = pos.X;
                top.value  = pos.Y;
                w.value    = pos.W;
                h.value    = pos.H;

                s.Value = "".PadRight(w.value - 1, '-');

                System.Threading.Thread.Sleep(50);
            }

            debugger.Abort();

            Console.ReadLine();
        }