public static void DrawFrame(Frame frame) // used to draw the actual frames of the parts of the game { // TODO: implement how to draw simple rectangular shapes on the console Point currentPoint = frame.TopLeft; // set the position to draw at Draw.WriteString("╔", new Point(currentPoint.X, currentPoint.Y)); // draw the up left corner currentPoint = frame.TopRight; // set next position Draw.WriteString("╗", new Point(currentPoint.X, currentPoint.Y)); // draw up right corner currentPoint = frame.BottomLeft; // set next position Draw.WriteString("╚", new Point(currentPoint.X, currentPoint.Y)); // draw low left corner currentPoint = frame.BottomRight; // set next position Draw.WriteString("╝", new Point(currentPoint.X, currentPoint.Y)); // draw low right corner // now lets draw the vertical lines for (int lenght = 0; lenght < frame.Height - 1; lenght++) { currentPoint = frame.TopLeft; // set current position Draw.WriteString("║", new Point(currentPoint.X, currentPoint.Y + lenght + 1)); // draw vertical line from the current position + the lenght vertical, this for left side currentPoint = frame.TopRight; // set the other position Draw.WriteString("║", new Point(currentPoint.X, currentPoint.Y + lenght + 1)); // draw vertical line from the current position + the lenght vertical, this for right side } // now draw the horiozontal lines for (int lenght = 0; lenght < frame.Width - 1; lenght++) { currentPoint = frame.TopLeft; // set starting point Draw.WriteString("═", new Point(currentPoint.X + lenght + 1, currentPoint.Y)); currentPoint = frame.BottomLeft; // set down side position Draw.WriteString("═", new Point(currentPoint.X + lenght + 1, currentPoint.Y)); } }
public static void DrawLogoInFrame(string[] logo, Frame frame, Style style) { Console.ForegroundColor = style.foregroundColor; // set color for thext Console.BackgroundColor = style.backgroundColor; // set background color int lenght = logo.Length; // count the items Point currentPoint = frame.TopLeft; // starting point for (int index = 0; index < lenght; index++) { Draw.WriteString(logo[index], new Point(currentPoint.X + frame.Width / 2 - logo[index].Length / 2, currentPoint.Y + frame.Height / 2 - lenght / 2 + index + 1)); } Console.ResetColor(); }
public static void DrawTextInFrame(string[] items, Frame frame, Style style) // used to draw text inside a frame of the game { // TODO: implement how to draw text inside a frame // completed Console.ForegroundColor = style.foregroundColor; // set color for thext Console.BackgroundColor = style.backgroundColor; // set background color int lenght = items.Length; // count the items Point currentPoint = frame.TopLeft; // starting point for (int index = 0; index < lenght; index++) { Draw.WriteString(items[index], new Point(currentPoint.X + frame.Width / 2 - lenght / 2, currentPoint.Y + frame.Height / 2 - lenght / 2 + index + 1)); } Console.ResetColor(); }
public static void ClearFrame(Frame frame, Style style) // to null frames for updating info { //TODO: implement clearing of the given frame with the given style Console.ForegroundColor = style.foregroundColor; // set color for thext Console.BackgroundColor = style.backgroundColor; // set background color int rows = frame.Height; int cols = frame.Width; Point currentPoint = frame.TopLeft; // starting point for (int i = 1; i < rows; i++) { for (int k = 1; k < cols; k++) { Draw.WriteString(" ", new Point(currentPoint.X + k, currentPoint.Y + i)); } } Console.ResetColor(); }
public string CheckInput() { int length = this.MenuItems.Length; Point currentPoint = this.MenuFrame.TopLeft; Point newPoint = new Point(currentPoint.X + this.MenuFrame.Width / 2 - length / 2, currentPoint.Y + this.MenuFrame.Height / 2 - length / 2 + 1); key = true; Draw.WriteString("►", new Point(newPoint.X - 2, newPoint.Y)); while (true) { ConsoleKeyInfo consoleKeyInfo = Console.ReadKey(true); key = consoleKeyInfo.Key != ConsoleKey.Enter; if (!key) { return(this.MenuItems[Position]); } key = consoleKeyInfo.Key != ConsoleKey.UpArrow; if (!key) { key = Position <= 0; if (!key) { Draw.WriteString(" ", new Point(newPoint.X - 2, newPoint.Y + Position)); Position--; Draw.WriteString("►", new Point(newPoint.X - 2, newPoint.Y + Position)); } } key = consoleKeyInfo.Key != ConsoleKey.DownArrow; if (!key) { key = Position >= MenuItems.Length - 1; if (!key) { Draw.WriteString(" ", new Point(newPoint.X - 2, newPoint.Y + Position)); Position++; Draw.WriteString("►", new Point(newPoint.X - 2, newPoint.Y + Position)); } } } }