示例#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();
        }
示例#3
0
        public static void RePlaceAllTiles(IRenderingApplication app, GMU g)
        {
            foreach (var item in garden)
            {
                PlaceImage(app, item.position.X, item.position.Y, BasicProvider.getInked(1, 1, item.getInfo()));
            }
            PlaceImage(app, (int)mower.posX, (int)mower.posY, BasicProvider.getInked(1, 1, new PInfo('O', ConsoleColor.Black, ConsoleColor.Gray)));

            List <GrasTile> tiles = new List <GrasTile>();

            foreach (var item in garden)
            {
                tiles.Add(item);
            }
            long maxCount = tiles.Where(y => y.cutAmount == tiles.Max(a => a.cutAmount)).ToList().Count;

            app.App_DrawScreen(BasicProvider.TextToPInfo("Mostvisited Tile: " + tiles.Max(x => x.cutAmount).ToString() + " -> " + tiles.Where(y => y.cutAmount == tiles.Max(a => a.cutAmount)).ToList().Count, width, 1, new PInfo(' ', ConsoleColor.White, ConsoleColor.Black)), height + 3, 3, null);


            g.PrintFrame();
        }
        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();
        }
示例#5
0
        public static void OnIdleHandle(Camera c, IRenderingApplication screen, GMU gmu)
        {
            ConsoleKeyInfo input;

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

            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();
        }
示例#6
0
        // here is how the distributes of rotation works

        #endregion


        static void Main(string[] args)
        {
            // setup the GMU
            Console.BackgroundColor = ConsoleColor.Black;
            Console.ForegroundColor = ConsoleColor.White;

            GMU gmu = new GMU(height + 10, width + 10);

            FullScreenManager screen = new FullScreenManager(height, width, gmu.PlacePixels);

            PlaceImage(screen, 0, 0, BasicProvider.getInked(width, height, new PInfo('A', ConsoleColor.Black, ConsoleColor.White)));
            gmu.PrintFrame();

            // x , y
            garden = new GrasTile[width, height];

            InitializeGarden();

            mower = new Mower(10, 10, Math.PI * 115 / 180);

            ConsoleKeyInfo input;

            while ((!Console.KeyAvailable))
            {
                foreach (var item in garden)
                {
                    PlaceImage(screen, item.position.X, item.position.Y, BasicProvider.getInked(1, 1, item.getInfo()));
                }

                //gmu.PrintFrame();
                Debug.WriteLine("angle: " + mower.angle * 180 / Math.PI + "°");

                /*switch (input.Key.ToString())
                 * {
                 *  case "RightArrow":
                 *      //mower.angle = mower.angle + Math.PI / 16;
                 *      //mower.UpdateVectorFromAngle();
                 *      break;
                 *  case "LeftArrow":
                 *      //mower.angle = mower.angle - Math.PI / 16;
                 *      //mower.UpdateVectorFromAngle();
                 *      break;
                 *  case "A":
                 *
                 *      break;
                 *  case "W":
                 *
                 *      break;
                 *  case "D":
                 *
                 *      break;
                 *  default:
                 *      break;
                 * }*/

                PlaceImage(screen, (int)mower.posX, (int)mower.posY, BasicProvider.getInked(1, 1, new PInfo('O', ConsoleColor.White, ConsoleColor.Gray)));
                gmu.PrintFrame();
                Queue <GrasTile> cutTiles = CalculateMowerUntilNextStop(false);

                mower = new Mower(mower.posX, mower.posY, mower.angle);

                if (cutTiles.Count > 0)
                {
                    //cutTiles.Dequeue();
                }

                foreach (var item in cutTiles)
                {
                    PInfo i = new PInfo();
                    i.background = ConsoleColor.DarkGray;
                    PlaceImage(screen, item.position.X, item.position.Y, BasicProvider.getInked(1, 1, i));
                }
                gmu.PrintFrame();

                //System.Threading.Thread.Sleep(1500);

                /*if (Console.KeyAvailable)
                 * {
                 *  Console.ReadKey(true);
                 * }*/

                CalculateMowerUntilNextStop(true);
                while (cutTiles.Count > 0)
                {
                    GrasTile tile = cutTiles.Dequeue();
                    tile.Cut();
                    PlaceImage(screen, tile.position.X, tile.position.Y, BasicProvider.getInked(1, 1, tile.getInfo()));
                    System.Threading.Thread.Sleep(waitTime);
                    gmu.PrintFrame();
                }

                RePlaceAllTiles(screen, gmu);
            }

            Console.ReadKey(true);
        }