Jump to content
  • Advertisement
Sign in to follow this  

SDL 2D particles tutorial

This topic is 2108 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts


It's not that difficult to have a working particle system:


create a Particle class (or struct) with attributes like




color / texture


life (how much time it "lives")

elapsed (start from 0 and increase at each frame by the amount of milliseconds elapsed)


then create a ParticleManager / Engine / whatever that 

- take care of start a particle effect

- updates each particle every frame

- destroys the particle effect at end


So, your particle engine will have to generate at some position given by you a certain number of Particles, each with a random position near its origin, a speed, a color etc.

At every frame check if

foreach p in Particles -> p.elapsed >= p.life

If yes, kills the particle, if not update its position by its speed and direction (and maybe color alpha)


When no particles remains, destroy and clear all.


Really, it's a nice and funny piece of code to work with and do some experiments

Share this post

Link to post
Share on other sites

ahah thank you


I wrote something in my native language (italian) on a blog of mine, but I'm not confident enough with my english to do more.


Anyway, just to add something to the topic, you can learn a lot by reading how other popular frameworks do the work. I have learned much this way, for example by the irrlicht engine code, which is very clear.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!