/// <summary> /// This method rotates the Pacman 90 degrees to the right without changing the position /// </summary> public void Right() { if (isValidCommand) { IMovement movement = MovementFactory.CreateMovementFromDirection(currentPosition.Dir); currentPosition.Dir = movement.Right(currentPosition.Dir); } }
/// <summary> /// This method moves the Pacman forward once in the direction it is facing /// </summary> public void Move() { //if command is valid i.e a place command was performaed before this, move forward once if (isValidCommand && isValidMove()) { //create Movement IMovement movement = MovementFactory.CreateMovementFromDirection(currentPosition.Dir); //perform move. Tuple <int, int> newPosition = movement.Move(currentPosition.X, currentPosition.Y); //update x and y co-ordinates currentPosition.X = newPosition.Item1; currentPosition.Y = newPosition.Item2; } }