Jump to content
  • Advertisement
Sign in to follow this  
TFS_Waldo

Best way to create a particle system (2D)??

This topic is 4837 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

Hey, and thanks for reading my post. I hope someone can give me an answer. Well, I am working on a 2D game, using OpenGL. Well, I want it to include explosions and other features with which I would like to use particles for the effects. But, I don't know exactly how to implement a particle system to handle explosions, etc. I am thinking about creating predefined patterns (ex. PST_EXPLOSION, PST_SMOKE, etc.), but I still don't know exactly how I should do it. If anyone else has done this, and can offer some code/advice I would really appreciate it. I have never really been much into using particle systems, because I never took the time to learn about them. But now I understand them. I just don't know how exactly I would implement a particle system for a 2D game. Any help is appreciated. Thanks! Thanks in advance, Matt U.

Share this post


Link to post
Share on other sites
Advertisement
Well, the way I've done it is as follows: define a particle structure, with values like origin, velocity, size, growth, friction, or color. Write a function that processess these values for each particle in existence in the scene, and draws them. You can have a spawning funtion, that finds a free particle in your array of particles, activates it, and sets up it's values. The individual particles can just be drawn with quads, or triangle strips, depending on how you want to do it.

Once you have a system to spawn and process individual particles, you could do things like explosions. For instance, spawn multiple particles with slightly varying origins and velocities all at the same time.

It's really not terribly difficult once you break it down to the mechanics, and isn't there a tutorial on nehe that describes a simple particle engine in detail?

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!