Game Development Reference
In-Depth Information
Managing Explosions and Enemies
In the last section, we got an example explosion working, but it really needs to be
set off only when enemies are destroyed. To this end, two new systems need
to be created: one to handle the explosions and general game effects, and one to
handle the oncoming enemies.
The explosions should be handled in a similar way to the bullets—creating a
dedicated manager that handles the creation and destruction of the explosions.
In the future of your project, it's possible you'll want more effects—smokes,
sparks, or even power ups—than explosions. The EffectsManager class
should be created in the Shooter project.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Engine;
namespace Shooter
{
public class EffectsManager
{
List < AnimatedSprite > _effects ¼ new List < AnimatedSprite > ();
TextureManager _textureManager;
public EffectsManager(TextureManager textureManager)
{
_textureManager ¼ textureManager;
}
public void AddExplosion(Vector position)
{
AnimatedSprite explosion ¼ new AnimatedSprite();
explosion.Texture ¼ _textureManager.Get("explosion");
explosion.SetAnimation(4, 4);
explosion.SetPosition(position);
_effects.Add(explosion);
}
public void Update(double elapsedTime)
{
 
Search WWH ::




Custom Search