Particle Explosion

Hi, I’m not sure if this is the right section for this kind of stuff, but I’ll post here anyway. I have an explosion class that draws lots of particles moving in random direction and forms a square explosion shape, I’m just wondering if there is a formula or algorithm I can use to create a circular explosion shape. Thanks in advance!

Here is some of my code for dealing with particles:
http://code.google.com/p/skorpios/source/browse/trunk/skorpios-common/src/com/esotericsoftware/skorpios/opengl/particles/Particles.java

The project also has an editor tool:
http://code.google.com/p/skorpios/source/browse/trunk/skorpios-desktop/tools/com/esotericsoftware/skorpios/tools/particles/ParticleEditor.java

Editor screenshot:

http://n4te.com/temp/sick.png

Basically you give each particle an angle (randomly distributed between 0 and 360 degrees to emit in all directions), and also a velocity (pixels per second is an easy unit). Then each update you change the position of the particle this way:


x += velocity * Math.cos(angle);
y += velocity * Math.sin(angle);

Note that Math.cos/sin takes an angle in radians.

Be sure to take into account the number of milliseconds that have passed since the last update when applying your velocity.

You may want to store precomputed values for velocityX and velocityY. I do the sin/cos each update because I allow my particles’ angle to change during its life.

Wow that’s pretty impressive stuff there…I’ll definitly dive deeper into the code once I get off work, thanks!

This is another one: http://sourceforge.net/projects/jops/, but seems unmaintained.

Cool, thanks for that link, I"ll take a look now XD

That formula there did the trick, thanks alot!