Point sprites are pretty common for particle engines these days. So, in the process of learning new things myself, and from my previous experience with my Four Elements 2002 entry ("Elements of Nature"), I decided to write an article about point sprites, and how to use them in a simple particle engine.
This tutorial is aimed at 2D, and the source will be in Visual Basic 6 and DirectX 8. Also note that this tutorial is meant for the people who do not have much or any experience with point sprites, or particle engines in general, and it won't involve much difficult math either.
I hope this tutorial will shed some light on particle engines, for programmers who are just starting with games (especially in VB). I also decided to make some simple examples of the interesting patterns or animations you can get with the extremely simple particle engine which is included with this tutorial. The full source included, of course. While creating this tutorial, I actually was amazed myself by the power of creating "particle stills" using the simple particle engine built in this tutorial.
What are particles?
Particles are individual objects, often controlled by gravity, by each other, "lifetime", and other factors, often reflecting real-world influences. All these "stand alone" particles need to be controlled. That's where the Particle Engine kicks in.
Particle engines are these days a commonly used piece of "machinery" in games. They are used for effects such as fire, smoke, and snow, and also for in-game effects like spawning new items, or picking up items, or animations around weapon projectiles. Particles can be used for many things. For example in the screenshot below, from my Four Elements Contest entery (2D) everything was made of particles, except for the ground, the tree (excepth for the leaves, which are particles), the lightning, the logos and the fish... So particles were used for the flowers, rain, clouds, the sun, the rainbow, leaves, fireflies and air bubbles!
It is also possible to use the particle engine to generate some particle-count heavy effects, and save a part of the framebuffer to disk. This way you can use the particle engine to pre-generate nice effects and then use them as textures in your game. For slower computers and older videocards this might help improve the framerate a lot, since it eliminates the need anymore to control every particle.
Another nice thing about particles is that, if you write a decent particle engine, you can have each individual particle controlled by external forces such as wind, gravity or neighboring particles. Complex formulas are also an option, which might result in interesting effects. We are going to keep it a bit simple here, so we will just stick with values like speed, acceleration and lifetime.