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 ...
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.