Time for action – building explosions

  1. Add the AddExplosion() method to the "Public Methods" region of the EffectsManager class:
    public static void AddExplosion( Vector2 location, Vector2 momentum, int minPointCount, int maxPointCount, int minPieceCount, int maxPieceCount, float pieceSpeedScale, int duration, Color initialColor, Color finalColor) { float explosionMaxSpeed = 30f; int pointSpeedMin = (int)pieceSpeedScale * 2; int pointSpeedMax = (int)pieceSpeedScale * 3; Vector2 pieceLocation = location - new Vector2(ExplosionFrames[0].Width / 2, ExplosionFrames[0].Height / 2); int pieces = rand.Next(minPieceCount, maxPieceCount + 1); for (int x = 0; x < pieces; x++) { Effects.Add(new Particle( pieceLocation, Texture, ExplosionFrames[rand.Next(0, ...

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.