O'Reilly logo

Beginning C++ Game Programming by John Horton

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required