public static void PlaceImage(IRenderingApplication app, int x, int y, PInfo[,] info) { PInfo[,] flipped = new PInfo[info.GetLength(0), info.GetLength(1)]; for (int ax = 0; ax < info.GetLength(0); ax++) { for (int ay = 0; ay < info.GetLength(1); ay++) { flipped[ax, info.GetLength(1) - ay - 1] = info[ax, ay]; } } app.App_DrawScreen(flipped, x + 2, (height - y - flipped.GetLength(1)) + 2, null); }
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(); }
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(); }