internal void GameLoop() { _gameBoard.InitiateGameBoard(); do { Console.Clear(); Console.WriteLine(Messages.ErrorMessage); Messages.ErrorMessage = string.Empty; _gameBoard.DrawGameBoard(_turtle.PositionX, _turtle.PositionY, _turtle.TurtleSymbol); Messages.Instructions(); Console.WriteLine("Pen is " + (_pen == Pen.PenActions.Down ? "drawing" : "not drawing") + "."); Console.WriteLine($"Turtle is moving {_direction}."); Console.Write("Select your option: "); if (int.TryParse(Console.ReadLine(), out _option)) { if (_option > 0 && _option < 3) { _pen = (Pen.PenActions)_option; } else if (_option > 2 && _option < 7) { _direction = (Directions.TurtleDirections)_option; Console.WriteLine($"Turtle is moving {_direction}."); Console.Write("Enter number of spaces to move: "); int spaces; if (int.TryParse(Console.ReadLine(), out spaces)) { _turtle.Walk(_direction, spaces, _pen); } else { Messages.InvalidInput(); } } else if (_option == 7) { _quit = true; } else { Messages.InvalidInput(); } } else { Messages.InvalidInput(); } } while (!_quit); }
public void GameLoop() { _gameBoard.InitGameBoard(); do { Console.Clear(); Console.WriteLine(Messages.ErrorMessage); Messages.ErrorMessage = ""; _gameBoard.DrawGameBoard(_turle.PositionX, _turle.PositionY, _turle.TurtleSymbol); Messages.Instructions(); Console.WriteLine(_pen); Console.WriteLine("Select your option: "); if (int.TryParse(Console.ReadLine(), out _option)) { if (_option > 0 && _option < 3) { _pen.PenAction = (Pen.PenActions)_option; } else if (_option > 2 && _option < 7) { Directions.TurtleDirections direction = (Directions.TurtleDirections)_option; Console.WriteLine($"Turtle is moving {direction}"); Console.WriteLine("Enter number of spaces to move: "); int spaces; if (int.TryParse(Console.ReadLine(), out spaces)) { _turle.Walk(direction, spaces, _pen.PenAction); } else { Messages.InvalidInput(); } } else if (_option == 7) { _quit = true; } else { Messages.InvalidInput(); } } else { Messages.InvalidInput(); } } while (!_quit); }
static void Main(string[] args) { int choice = 0; TurtleGraphics turtleGraphics = new TurtleGraphics(); Canvas canvas = new Canvas(); Turtle sandy = new Turtle(); while (choice != 9) { turtleGraphics.printOptions(); choice = Convert.ToInt32(Console.ReadLine()); switch (choice) { case 1: sandy.UpOrDown = 0; break; case 2: sandy.UpOrDown = 1; break; case 3: sandy.ChangeDirection(1); break; case 4: sandy.ChangeDirection(0); break; case 5: Console.WriteLine("How many steps?"); int a = Convert.ToInt32(Console.ReadLine()); sandy.Walk(a, ref canvas.floor); break; case 6: canvas.printFloor(); break; case 9: Console.WriteLine("THANKS!"); break; } } }