Building a particle system
Before we start coding, it will be helpful to see exactly what it is we are trying to achieve. Take a look at the following screenshot:
This is a screenshot of the particle effect on a plain background. We will use the effect in our game.
The way we achieve the effect is as follows:
- Spawn 1,000 dots (particles), one on top of the other, at a chosen pixel position.
- In each frame of the game, move each of the 1,000 particles outward at a predetermined, but random, speed and angle.
- Repeat step two for two seconds and then make the particles disappear.
We will use a VertexArray
to draw all the dots and the primitive type of Point
to represent each particle visually. Furthermore, we will inherit from Drawable
so that our particle system can take care of drawing itself.
Coding the Particle class
The Particle
class will be a simple class that represents just one of the 1,000 particles. Let's get coding.
Coding Particle.h
Right-click Header Files in the Solution...