Time for action – rotating pieces

  1. Open your existing Flood Control project in Visual C# Express if it is not already active.
  2. Add a new class to the project called "RotatingPiece".
  3. Add "using Microsoft.Xna.Framework;" to the using area at the top of the class.
  4. Update the declaration of the class to read class RotatingPiece : GamePiece.
  5. 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;
  6. Add a property to retrieve the current rotation amount:
    public float RotationAmount
    {
        get 
        {
            if (clockwise)
                return rotationAmount;
            else
                return (MathHelper.Pi*2) - rotationAmount;            
        }
    }
  7. Add a constructor for the ...

Get XNA 4.0 Game Development by Example Beginner's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.