Implementing a Basic Particle System

You can think of a particle system as a system that generates small pieces of materials which are responding to some sort of environmental change. For example, a particle system could generate snowflakes, fog, sparks, or dust. In Tankers, you have a tank firing a projectile out of its barrel. Adding a small bit of spark particles to this firing should be easy to do.

Direct3D uses point sprites to render these particles. In the context of Direct3D, they are essentially generalizations of points in space that are rendered using textures. Adding them is also quite simple. In your project file, add a new file called specialeffects.cs and add the code from Listing 18.1 to the code file.

Listing 18.1. Starting the ...

Get Beginning 3D 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.