Time for action – GamePiece class methods – part 2 – rotation
Add the
RotatePiece()
method to theGamePiece
class:Public Sub RotatePiece(clockwise As Boolean) Select Case _pieceType Case "Left,Right" _pieceType = "Top,Bottom" Case "Top,Bottom" _pieceType = "Left,Right" Case "Left,Top" If (clockwise) Then _pieceType = "Top,Right" Else _pieceType = "Bottom,Left" End If Case "Top,Right" If (clockwise) Then _pieceType = "Right,Bottom" Else _pieceType = "Left,Top" End If Case "Right,Bottom" If (clockwise) Then _pieceType = "Bottom,Left" Else _pieceType = "Top,Right" End If Case "Bottom,Left" If clockwise Then _pieceType = "Left,Top" Else _pieceType = "Right,Bottom" End If End Select End Sub
What just happened?
The only information the RotatePiece()
method needs is a rotation direction. For straight pieces, rotation direction...