Time for action – rotating pieces
Open your existing Flood Control project in Visual Studio, if it is not already active.
Add a new class to the project called
RotatingPiece
.Under the class declaration (
Public Class RotatingPiece
), add the following line:Inherits GamePiece
Add the following declarations to the
RotatingPiece
class:Public Clockwise As Boolean Public Shared RotationRate As Single = (MathHelper.PiOver2/10) Private _rotationAmount As Single Public rotationTicksRemaining As Single = 10
Add a property to retrieve the current
RotationAmount
:Public ReadOnly Property RotationAmount As Single Get If Clockwise Then Return _rotationAmount Else Return (MathHelper.Pi * 2) - _rotationAmount End If End Get End Property
Add a constructor for the
RotatingPiece
class as follows:Public Sub New(type As String, clockwise As Boolean) MyBase.New(type) Me.Clockwise = clockwise End Sub
Add a method to update the piece as follows:
Public Sub...