Explosion tutorial
I mentioned this a while ago, but here it finally is: a tutorial about explosions in Torque Game Builder. I’m gonna show you how to make a simple explosion with Torque’s particle engine. It will be only a fireball, no ejected fragments, sparks, plasma rings or anything like that. Just a very basic explosion.
We’re gonna start by creating a particle sprite. This will be the particle the explosion will be made of. For this, I used The Gimp. I created a 64×64 pixel image with a black background (used for viewability purposes, this will be removed later) and made a transparent layer on top of this. In this layer I drew the particle with the paintbrush. I used the ‘Galaxy, Small’ brush with an opacity of 50%. Next, I applied Gaussian Blur with a radius of five pixels and the black background layer is hidden. This image is saved as particle.png; it is very important to save it as a png file, since this format contains an alpha channel!
That’s it for the drawing part. Import particle.png into Torque Game Builder as a static sprite and create a new particle effect. This one uses only one emitter, so you can use the default one. Start by setting the effect mode to ‘CYCLE’ and the effect lifetime to 3 seconds. Next, open the emitter settings and make sure all checkboxes are unchecked, except ‘Fixed aspect’ and ‘Intense particles’. Select the particle image in the ‘Image’ field. The emitter should now start to emit a cloud of bright white particles. Doesn’t look like an explosion yet, though.
We start by specifying the number of particles. To get an explosion effect, the emitter should emit a short, intense burst of particles. For this, open the emitter graph editor and select ‘Quantity base’. Set the value axis to 0/50 and the time axis to 0/1, so it’s easier to set the right values. At 0 seconds, the emitter should emit 50 particles and at 1 second, this should be zero. This makes the emitter burst particles for 1 second.
The effect now looks like a ring of particles. In some cases this can be the desired effect, but not this time. We need a solid ball of flames. To achieve this effect, we need to adjust the particle speed settings. First of all, the base speed is set to one. This is just the base speed that’s used to calculate all other speeds. Speed variance is set to two. This makes sure not all particles move at the same speed. The third setting, speed life, is what makes the fireball come to life. I set the speed axis to 0/2 and the time axis to 0/1. You’ll need to play around with the graph a bit and see what the effect of different settings is.
We have now a pulsating explosion, but one thing is still missing: color! I used a white particle sprite so it’s easy to adjust the final color using the RGB graphs. In the emitter graph, there are three options named ‘Red color life’, ‘Green color life’ and ‘Blue color life’. First of all, set the blue color to 0. This will turn the explosion yellow. The red component will remain at 1. The key to turning it into a bright orange fireball wich will fade to red is the green component. This starts at 0.5 and drops to 0.2 after one second in this example.
And finally, to finish it, the visibility should drop to zero. This is done with the visibility life graph, wich drops from 1 at 0 seconds to 0 at 0.8 seconds.
To change the appearance of the explosion, you should experiment a bit with all the settings so you can see what the effect is. You can download the effect and image, so you can try it out for yourself.

Leave a Reply