Time for action – rotating pieces
Open your existing Flood Control project in Visual C# Express if it is not already active.
Add a new class to the project called "RotatingPiece".
Add "
using Microsoft.Xna.Framework;
" to theusing
area at the top of the class.Update the declaration of the class to read
class RotatingPiece : GamePiece
.Add the following declarations to the RotatingPiece class:
public bool clockwise; public static float rotationRate = (MathHelper.PiOver2 / 10); private float rotationAmount = 0; public int rotationTicksRemaining = 10;
Add a property to retrieve the current rotation amount:
public float RotationAmount { get { if (clockwise) return rotationAmount; else return (MathHelper.Pi*2) - rotationAmount; } }
Add a constructor for the RotatingPiece class:
public RotatingPiece(string pieceType, bool clockwise) : base(pieceType) { this.clockwise = clockwise; }
Add a method to update the piece:
public void UpdatePiece...