Time for action – the Particle class

  1. Add a new class file to the Robot Rampage project called Particle.cs.
  2. Add the following using directives to the Particle class:
    using Microsoft.Xna.Framework;
    using Microsoft.Xna.Framework.Graphics;
  3. Update the class declaration for the Particle class to derive it from the Sprite class:
    class Particle : Sprite
  4. Add declarations to the Particle class:
    #region Declarations
    private Vector2 acceleration;
    private float maxSpeed;
    private int initialDuration;
    private int remainingDuration;
    private Color initialColor;
    private Color finalColor;
    #endregion
  5. Add properties to the Particle class:
    #region Properties public int ElapsedDuration { get { return initialDuration - remainingDuration; } } public float DurationProgress { get ...

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.