Time for action – building explosions
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, ExplosionFrames.Count)], randomDirection(pieceSpeedScale) + momentum, Vector2.Zero, ...