Sign in to follow this  

Particle Systems Tutorial

Recommended Posts

Hi guys! I'm looking for particle systems tutorial especially those that relate to allegro game library. I want to try a few and choose which ones would fit into my game(2D Sidescrolling shooter). I prefer those that has explosion, laser or anything else related to fire and light. Thank you!

Share this post

Link to post
Share on other sites
I don't know of any specific Tutorials for Particle Engines in Allegro, not that I've been looking. To get you thinking though, I'll give you a rundown on the types of variables you might need when modelling an actual particle. Once you know the variables you need to make a single particle work, you can probably figure out the rest for yourself (Modelling a collection of Particles, for instance).

Position- Position of Particle.
ActingForce- Force currently being applied to Particle. Every update, Position += ActingForce, basically.
Bounce- How much the particle will bounce when it hits another object (eg Ground)
Weight- Weight of the Particle. Heavier = Falls Faster.
Size- Mostly for Aesthetic purposes. You wouldn't want all particles to be of uniform size would you :)?
Drag (or Drag Coefficient)- Vertical and Horizontal drag applied to Object. That is, ActingForce += -(ActingForce * Drag). So a particle with a high 'Drag' will not be able to acheive a high speed (You could think of this as how 'Aerodynamic' the particle is).
Color- Color of Particles. For more variety, specify a Min/Max color. For even more, specify a 'Fade'/'Change' color. IE, evey update, Color += FadeColor.
Age- Current Age and Max age of Particle. Have a Min/Max die age, so not all particle die at exactly the same time.

Anyway, thats just a (reasonably) quick list. I'm sure you can apply your Allegro knowledge with it to make a decent Particle System.

Good Luck :)

Also, note: I'm only 16, and haven't done any Physics at school yet, so some stuff I said might not be right (Do heavier objects fall faster, or is it to do with Mass, or Resistance or something? lol).

Share this post

Link to post
Share on other sites
And I'm 21 :)

Thanks! I actually already had that in my mind but wasn't confident enough to actually implement it.

Anyway... I was thinking of my class structure. Perhaps someone could help me more with this one then?

If I have a class Sprite, then I have other classes which is Ship and Enemy and other classes also derive from these two...

Sprite -> Ship -> DerivedShipClass

Sprite -> Enemy -> DerivedEnemyClass

then perhaps I will have a class Particle that also derives from Sprite

Sprite -> Particle

A particle when would be like for instance, a single dot. If I had to make let's say 600 particles then where should I store these 600 particles? What I have in mind right now is like

a vector member in class Sprite?
a vector member in class Ship/Enemy or derived class?

What do you think guys? Thanks!

Share this post

Link to post
Share on other sites
I'd write a ParticleEmitter class or something along that line, that manages the lifetime and updating of the particles it emits (whether those are dots or Sprites or whatever). Whenever you detect a collision or such, you simply create a ParticleEmitter instance and give it some basic instructions, like how many particles to emit per second, how long to stay active, etc.

Share this post

Link to post
Share on other sites
I'd say keep it entirely separate from the Player/Enemy classes.

I propose: Particle Engine-> Collection of Particle Emitters-> Collection of Particles.

Allow Particle Emitters to either have a static location, or allow them to be 'attached' onto Player/Enemy classes (Thru a Pointer to the Player/Enemy, and just render the emitter at the Player/Enemys location).

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this