/// <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; }
public void UpdateBuffer(DrawPoint[,] Buffer) { if (SafeGaurdBuffer != Buffer) { this.SafeGaurdBuffer = DrawPoint.CopyTo(Buffer, this.SafeGaurdBuffer); DrawScreen(); } CurrFrames++; }
void DrawScreen() { Buffer = DrawPoint.CopyTo(SafeGaurdBuffer, Buffer); switch (LTRTTB_TTBLTR) { case false: for (int y = 0; y < Height; y++) { for (int x = 0; x < Width; x++) { if ((Buffer[x, y].DisplayChar != CurrDisplay[x, y].DisplayChar) || (Buffer[x, y].DisplayColor != CurrDisplay[x, y].DisplayColor) || ForceDraw) { DrawToPoint(x, y); } ; } } break; case true: for (int x = 0; x < Width; x++) { for (int y = 0; y < Height; y++) { if ((Buffer[x, y].DisplayChar != CurrDisplay[x, y].DisplayChar) || (Buffer[x, y].DisplayColor != CurrDisplay[x, y].DisplayColor) || ForceDraw) { DrawToPoint(x, y); } } } break; } Console.SetCursorPosition(0, 0); ForceDraw = false; CurrDisplay = DrawPoint.CopyTo(Buffer, CurrDisplay); }