Exemple #1
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 #3
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();
            }
        }