Particle Effects

Particle Effects

As a child camping isn’t what I would have called my favorite activity. The most memorable part for me was always putting together a nice fire and watching how they burned. No matter how many times I had seen them they always managed to amaze and entertain me.


The sample program uses particles to create the flame effect. Particles are quite common in video games, one example being the classic game Asteroids which used particles for the explosions. Particles are generally used for aesthetic purposes to provide extra detail to animations.

The code for the particle class is below. The particles use PVectors for the position and velocity variables as a vector is used to store both an x and y value. The position is instantiated with arguments from the constructor whereas the velocity is calculated based off of the direction of the particle. Each particle is given a “life” value which is slightly randomized which determines how long it will appear on screen. The particles movement is also slightly randomized to create more natural movement rather than having particles that move straight in one direction.

The code for the rest of the demo can be found down below or at:

Leave a Reply

Your email address will not be published. Required fields are marked *