Time for action – modify Game1 to generate rotating pieces
Update the
HandleMouseInput()
method in theGame1
class to add rotating pieces to the board by adding the following inside the"if mouseInfo.LeftButton = ButtonState.Pressed"
block, before _gameBoard.RotatePiece()
is called:_gameBoard.AddRotatingPiece(x, y, _gameBoard.GetSquare(x, y), False)
Still in
HandleMouseInput()
, add the following in the same location inside theif
block for the right-mouse button:_gameBoard.AddRotatingPiece(x, y, _gameBoard.GetSquare(x, y), True)
What just happened?
Recall that the only difference between a clockwise rotation and a counter-clockwise rotation (from the standpoint of the AddRotatingPiece()
method) is a true or false in the final parameter. Depending on which button is clicked, we simply add the current square (before it gets rotated, otherwise the starting point for the animation would be the final position) and true for right-mouse clicks or false for left-mouse clicks.