I also added explosions and sound.
The new classes I created can be used for any 2D XNA game.
The tutorial is here: http://creators.xna.com/en-US/education/gettingstarted/bg2d/chapter1Explanations and demo of explosions: http://creators.xna.com/en-US/sample/particle
The demo project with the new classes: http://www.megaupload.com/?d=NEMV4EF3
Screenshot:
Most of the code can't be figured from the screenshot.
I created some generic classes to represent static objects, moving objects, particles, and particles systems. I wrote the most important things about some classes:
- class GameObject2 : DrawableGameComponent
- Represents a static 2D object
- Has the following additional properties:
- Texture
- Position
- Center
- Rotation
- Scale
- DestinationRectangle
- CenterPosition
- Active
- SourceRectangle
- Color
- Effects
- LayerDepth
- SpriteBlendMode
- Has 8 different constructors for different purposes
- Overrides Draw() method
- class MovingGameObject2 : GameObject2
- Represents an 2D object that moves
- Has the following additional properties:
- Velocity
- Acceleration
- RotationSpeed
- TimeSinceInit
- Overrides Update() method
- class Particle2 : MovingGameObject2
- Represents a 2D particle like in an explosion
- Has a Lifetime property
- Overrides Update() method
- abstract class ParticleSystem2 : GameObject2
- Represents a 2D particle system that can be used for explosions, smoke etc.
- Has the following protected parameters:
- rangeParticlesPerEffect
- rangeVelocity
- rangeAcceleration
- rangeRotation
- rangeRotationSpeed
- rangeScale
- rangeLifetime
- Each new particle gets a random value for each parameter from its range
- Overrides Draw() and Update() methods