Page 1 of 1

Particle Systems

Posted: Sat Mar 27, 2010 8:38 pm
by XianForce
Well, I want to make a particle system (a very basic one at that). I'm curious as to how I should set it up.

Obviously I'll have a particle class which will have a rect for positioning/size, a velocity vector, a life integer, and perhaps an acceleration vector.

Then I'd have some sort of Particle System class which would manage all the particles. But what sort of operations do these classes need to accomplish to produce different effects?


If it's of any use: I want to make a particle system, because I've been working on a Breakout game. Currently, every time a brick is hit, it loses life, and it's color becomes less intense. Once it is destroyed, I want it to break into particles and have all the particles float down.

Re: Particle Systems

Posted: Sat Mar 27, 2010 9:19 pm
by RyanPridgeon
A simple particle system, say for an explosion, will generate a bunch of particles at a given position which all have random velocities. The particles could maybe fade out over time before being destroyed and have a nice texture / colour. This would give reasonable results and be very simple.

For the classes, well obviously you'd want velocity, position, a timer\ and rendering information for each particle, with functions for creating, updating, drawing and deleting the particle. The manager would just need some kind of list (like a C++ vector) for holding references or pointers to each particle, and call the update and creation of the particles from functions like CreateParticle(x, y) or ExplosionAt(x, y) for example.