public void MoveUp(ConsoleRectangle rect) { if (rect.Location.Y == 0) { Console.WriteLine("Cant go higher"); return; } rect.Location.Y--; rect.Draw(); }
public void MoveLeft(ConsoleRectangle rect) { if (rect.Location.X == 0) { Console.WriteLine("Cant go out of border"); return; } rect.Location.X--; rect.Draw(); }
public void Run() { Console.SetWindowSize(110, 35); ConsolePrinter printer = new ConsolePrinter(); // X and Y will initially be set to 0,0 ; // Create new Instance of Point to modify ConsoleRectangle rect = new ConsoleRectangle(10, 5, new Point()); rect.Draw(); while (true) { var inputChar = printer.ReadInput(); Console.Clear(); Move(inputChar, rect); } }
private static void Move(ConsoleKey input, ConsoleRectangle rect) { switch (input) { case ConsoleKey.Escape: return; case ConsoleKey.UpArrow: rect.MoveUp(rect); break; case ConsoleKey.DownArrow: rect.MoveDown(rect); break; case ConsoleKey.LeftArrow: rect.MoveLeft(rect); break; case ConsoleKey.RightArrow: rect.MoveRight(rect); break; case ConsoleKey.R: Console.Write("Width: "); int width = Convert.ToInt32(Console.ReadLine()); Console.Write("Height: "); int height = Convert.ToInt32(Console.ReadLine()); rect = rect.Resize(width, height); Console.Clear(); rect.Draw(); break; } }
public void MoveDown(ConsoleRectangle rect) { rect.Location.Y++; rect.Draw(); }
public void MoveRight(ConsoleRectangle rect) { rect.Location.X++; rect.Draw(); }