Best way to create a particle system (2D)??
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.
:==-_ Why don't the voices just leave me alone?! _-==:
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?
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?
~Script
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement