/// <summary> /// Initiates a draw object /// </summary> /// <param name="width">Width of display</param> /// <param name="height">Height of display</param> /// <param name="StartBuffer">First buffer screen to display</param> /// <param name="Title">Title of console program</param> public Draw(int width, int height, DrawPoint[,] StartBuffer, string Title) { Console.CursorVisible = false; this.Width = width; this.Height = height; this.CurrDisplay = DrawPoint.Const(' ', Color.White, new DrawPoint[width, height]); this.Buffer = DrawPoint.CopyTo(StartBuffer, new DrawPoint[width, height]); this.SafeGaurdBuffer = DrawPoint.CopyTo(StartBuffer, new DrawPoint[width, height]); if (Console.BufferHeight < Height) { Console.BufferHeight = Height; } if (Console.BufferWidth < Width) { Console.BufferWidth = Width; } if (Console.WindowHeight < Height) { Console.WindowHeight = Height; } if (Console.WindowWidth < Width) { Console.WindowWidth = Width; } Console.Title = Title; }
void SETUP(int ScreenWidth, int ScreenHeight, string GameName, bool LTRTTB_TTBLTR) { Camera = new Object("CAMERA", new Vector2(ScreenWidth, ScreenHeight), new Vector2(0, 0)); DisplayBuffer = DrawPoint.InitPoint(ScreenWidth, ScreenHeight); DisplayBuffer = DrawPoint.Const(BackgroundChar, Background, DisplayBuffer); Renderer = new Draw(ScreenWidth, ScreenHeight, DisplayBuffer, GameName); Renderer.LTRTTB_TTBLTR = LTRTTB_TTBLTR; Renderer.Start(); AddObject(Camera); }
//NOTE: there are still some weird artifacts going on as if something is being rounded the wrong way --- no idea if this is still the case i hafta look into it - TODO //yes there are indeed still some artifacts around the 0 coordinate but that will hafta wait public void RenderScreen() { Vector2 localPos; Vector2 AdditionVector; Vector2 LastPos; GetCollision(Camera); DisplayBuffer = DrawPoint.Const(BackgroundChar, Background, DisplayBuffer); for (int i = 0; i < Camera.CollidingObjects.Count; i++) { if (Camera.CollidingObjects[i].Visible) { if (Camera.CollidingObjects[i].NAME != Camera.NAME && !Camera.CollidingObjects[i].TEXT_OBJ) { LastPos = Camera.CollidingObjects[i].GetPos() - 1; localPos = Camera.LocalizePos(Camera.CollidingObjects[i]); if (Camera.CollidingObjects[i].GetSize() > 1) { localPos -= Camera.CollidingObjects[i].GetSize() / 2; } for (int y = 0; y < Camera.CollidingObjects[i].GetSize().y; y++) { AdditionVector = Vector2.Copy(localPos); LastPos.y = y + localPos.y - 1; if (LastPos.y == ExMath.Round(y + localPos.y)) { AdditionVector.y++; } for (int x = 0; x < Camera.CollidingObjects[i].GetSize().x; x++) { LastPos.x = x + localPos.x - 1; if (LastPos.x == ExMath.Round(x + localPos.x)) { AdditionVector.x++; } DisplayBuffer = DrawPoint.InsertAsMiddle(DisplayBuffer, (int)ExMath.Round(x + AdditionVector.x), (int)ExMath.Round(y + AdditionVector.y), '#', Camera.CollidingObjects[i].Color); } } } else if (Camera.CollidingObjects[i].TEXT_OBJ) { localPos = Camera.LocalizePos(Camera.CollidingObjects[i]); string[] TEXT = Camera.CollidingObjects[i].Text.Split("\r\n"); for (int y = 0; y < TEXT.Length; y++) { for (int x = 0; x < TEXT[y].Length; x++) { DisplayBuffer = DrawPoint.InsertAsMiddle(DisplayBuffer, (int)ExMath.Round(x + localPos.x), (int)ExMath.Round(localPos.y - y), TEXT[y][x], Camera.CollidingObjects[i].Color); } } } } } Renderer.UpdateBuffer(DisplayBuffer); }