Page 1 of 1
Particle Systems
Posted: Tue May 18, 2010 7:57 pm
by ajtgarber
How would you go about writing a particle system?
I have an extremely basic understanding of them, and I've seen them in action but I'm still not quite sure how to go about making one.
More specifically:
What attributes would a particle have?
How do you keep them from clumping?
Do you randomly generate the positions within a boundary or do you start them all at a point and modify their directions?
What would be a good particle limit?
Would you draw them as rectangles or as circles? (or does it even matter?)
Sorry for all the questions
Re: Particle Systems
Posted: Tue May 18, 2010 7:58 pm
by ajtgarber
Oh and just for the record, this is supposed to be a 2D particle system :P
Re: Particle Systems
Posted: Tue May 18, 2010 8:16 pm
by eatcomics
This should help:
http://paraschopra.com/tutorials/particle-systems/
rather than someone doing a tutorial for ya, if you have any questions just ask :D
Re: Particle Systems
Posted: Tue May 18, 2010 9:12 pm
by mv2112
Attributes:
Position(x,y)
Size
color
isAlive(Boolean)
life_span
force(x,y) or velocity, same thing
gravity(Boolean)
To keep from clumping I generate a random float between -.1 and .1 and add it the the particles x and y
I start the particles at a point and modify there velocity.
I have a 10,000 particle limit
I use SDL_FillRect to draw them
For a particle manager, make sure you have any array of particles rather than allocating new ones each time, arrays go ALOT faster.
Re: Particle Systems
Posted: Tue May 18, 2010 9:51 pm
by eatcomics
since you won't have more than your limit, and array should be fine
although if you were handling a vector manually I think it would be fine? I don't know for sure
Re: Particle Systems
Posted: Tue May 18, 2010 10:35 pm
by Ginto8
eatcomics wrote:since you won't have more than your limit, and array should be fine
although if you were handling a vector manually I think it would be fine? I don't know for sure
A vector with a certain amount of memory reserve()'d should be pretty fast, but a limit on the amount of particles is still the best idea for performance.
Re: Particle Systems
Posted: Wed May 19, 2010 8:47 am
by mv2112
Particle Systems are some what easy to make if you think about particles in a OO way.
I just made one 0_o
Re: Particle Systems
Posted: Wed May 19, 2010 5:29 pm
by eatcomics
This is where you pull a marcel and say, "I would help, but I have no idea how particle systems work"
Re: Particle Systems
Posted: Thu May 20, 2010 8:46 pm
by ajtgarber
Thanks!