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:

Building a particle system

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:

  1. Spawn 1,000 dots (particles), one on top of the other, at a chosen pixel position.
  2. In each frame of the game, move each of the 1,000 particles outward at a predetermined, but random, speed and angle.
  3. 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

Get Beginning C++ Game Programming 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.