This toy is a particle system. This particular particle system creates an explosion that is similar to the explosions found in Capcom’s games, like Metal Slug.
How it works
There is the initial explosion which starts with a set amount of particles. Then there is a chance that these particles will spawn littler particles to propagate the initial explosion. The explosion will start off flaring and as the initial particles start dying the effect moves into trail particles and finally finishes off with smoke particles. Additionally, there is a glow around the explosion. You can save the generated explosion and you can download the class that I created for this effect.
The whole premise is simple. The toy starts with the initial particles, which have a chance to explode into children particles. These children particles have a further chance of breaking into baby particles, and this process is repeated until the end. The type of particles created change over the life-cycle of the explosion. The life-cycle phases are Explosion > Flare > Trail > Smoke. You can control each phase of the life-cycle… and more.
- The toy is a particle system
- Each frame is calculated and saved to a bitmap
- The frames are put sequentially after each other, horizontally, on a bitmap
- A mask is applied to the bitmap to show a single frame
- The animation is created by moving the mask over the bitmap or by moving the bitmap under the mask
- You can fiddle with the settings of the explosion, but none of the changes will take effect until a new explosion is generated
- If the particle system carries on for too long, then you hit the upper limit for a bitmap-width and it crashes
- Lots of particles take a long time to generate and calculate
- The toy pauses for quite a while when generating, around 5 seconds with the default settings
- Scaling-up quickly reduces the amount of frames allowed before breaking the bitmap-width limit
- Encapsulated it into one class
- Exposed only the essentials
- Parametarised most of the variables, hence the cramped controls
- Changed the variable names to something more descriptive
- Used a vector class for the particle direction and speed calculations
- Incorporated Grant Skinner’s seeded number generator
Have fun with the toy. Remember that you can save your creation and download the code.