Particle Systems

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

Post Reply
ajtgarber
Chaos Rift Cool Newbie
Chaos Rift Cool Newbie
Posts: 97
Joined: Wed Jun 10, 2009 8:56 am

Particle Systems

Post 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
ajtgarber
Chaos Rift Cool Newbie
Chaos Rift Cool Newbie
Posts: 97
Joined: Wed Jun 10, 2009 8:56 am

Re: Particle Systems

Post by ajtgarber »

Oh and just for the record, this is supposed to be a 2D particle system :P
User avatar
eatcomics
ES Beta Backer
ES Beta Backer
Posts: 2528
Joined: Sat Mar 08, 2008 7:52 pm
Location: Illinois

Re: Particle Systems

Post 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
Image
User avatar
mv2112
Chaos Rift Junior
Chaos Rift Junior
Posts: 240
Joined: Sat Feb 20, 2010 4:15 am
Current Project: Java Tower Defence Game
Favorite Gaming Platforms: N64/Xbox 360/PC/GameCube
Programming Language of Choice: C/++, Java
Location: /usr/home/mv2112
Contact:

Re: Particle Systems

Post 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.
User avatar
eatcomics
ES Beta Backer
ES Beta Backer
Posts: 2528
Joined: Sat Mar 08, 2008 7:52 pm
Location: Illinois

Re: Particle Systems

Post 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
Image
User avatar
Ginto8
ES Beta Backer
ES Beta Backer
Posts: 1064
Joined: Tue Jan 06, 2009 4:12 pm
Programming Language of Choice: C/C++, Java

Re: Particle Systems

Post 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.
Quit procrastinating and make something awesome.
Ducky wrote:Give a man some wood, he'll be warm for the night. Put him on fire and he'll be warm for the rest of his life.
User avatar
mv2112
Chaos Rift Junior
Chaos Rift Junior
Posts: 240
Joined: Sat Feb 20, 2010 4:15 am
Current Project: Java Tower Defence Game
Favorite Gaming Platforms: N64/Xbox 360/PC/GameCube
Programming Language of Choice: C/++, Java
Location: /usr/home/mv2112
Contact:

Re: Particle Systems

Post by mv2112 »

Particle Systems are some what easy to make if you think about particles in a OO way. :mrgreen:
I just made one 0_o
User avatar
eatcomics
ES Beta Backer
ES Beta Backer
Posts: 2528
Joined: Sat Mar 08, 2008 7:52 pm
Location: Illinois

Re: Particle Systems

Post by eatcomics »

This is where you pull a marcel and say, "I would help, but I have no idea how particle systems work"
Image
ajtgarber
Chaos Rift Cool Newbie
Chaos Rift Cool Newbie
Posts: 97
Joined: Wed Jun 10, 2009 8:56 am

Re: Particle Systems

Post by ajtgarber »

Thanks! :)
Post Reply