Fun with 2D particles using emitters and waypoints

I was thinking about playing with particle systems the other week after I’d been creating a Vec2 class to easily work with two-dimensional vectors, so I decided to make one. Check it out:

The basics are that:

  • The entire thing is a ParticleSet2D. You can create as many of these as you like.
  • Each ParticleSet2D has at least one (but as many as you want) ParticleEmitter2D objects, and at least one (but again, as many as you want) ParticleWaypoint2D objects.
  • A ParticleEmitter2D can be placed at any location, and emits a new Particle2D at a given time interval, for example 0.1 would give 10 new particles per second, 0.05 would give you 20 particles per second etc.
  • On creation, a particle heads towards the first waypoint in the vector (i.e. dynamically resizable array) of waypoints. When it reaches within a given distance of the waypoint its speed gets jumbled a bit and it then heads towards the next waypoint.
  • When it hits the last waypoint the particle is destroyed.

There’s lots more of course, like you can control how fast the particles move, how tightly they corner etc, and it’s all written in a completely framerate independent manner using delta-time values so it can run at 10fps and trace out the same patterns as at 120fps (which actually took quite a bit of doing).

Anyways, all for fun. I’ve also migrated it to 3D, but I’m not happy with the point-sprite size attenuation details matching the view frustum so I’ll rewrite it using quads soon and post it up also.

Fun & games =D

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.