Arcade explosion generator
Over the past few weeks I've been messing around creating a unique graphics for our Jewel Rush game. One of the things I was experimenting with was explosion animations. Although tools exist for generating explosions the problem with most of these is that they create large sprites which don't shrink well, and the output is a bit more realistic than what I was looking for.
And while I'm competent enough to do application graphics (more or less!), gaming graphics are a completely different kettle of fish!
Above is a screenshot from Missile Command, a classic from Atari. That's the sort of explosions I wanted to create, so I wrote a small tool that would create these sort of graphics in a random (but reproducible) fashion and export them to images for use in other tools such as Spriter. As it turned out, the graphics it produces didn't end up quite that way (I was having problems with the intersection stuff) but it's usable enough for the purposes I want.
The application was thrown together over the weekend so it's probably not hugely robust and may contain a small army of bugs. But it works and is possibly an interesting starting point for other projects. There's some interesting bits of code here and there, although I'm not writing about the implementation of the code.
- Configuration settings can be saved and reloaded for tweaking of favoured settings. Uses basic Reflection serialization as
XmlSerializercan't handle colors without having to create duplicate color properties in string format.
- Can export either a complete sprite sheet, or the individual images
- Copy the sprite sheet to the clipboard (although I noticed that transparent doesn't work if you do, something to look at later)
- Uses the ImageBox (of course!) for displaying previews
TrackBarcontrol embedded in the
ToolStripis a custom component inheriting from
ToolStripControlHostwhich can be reused. And once you understand the principles, it's so easy to host other controls.
- Either specify a seed to always recreate the same explosion, or use a random seed each time. (If you find a seed you like, clicking the seed number in the status bar will apply it to your configuration settings).
- Specify the number of animation frames that will be generated, and the size of the frames
- Specify the maximum number of explosion booms available at once. There's also an option to automatically remove and recreate "expired" blooms.
- Choose the colors used to render the bloms
- Specify the percentage by which blooms grow (and shrink), and how many growth states there are. Once a bloom has shrunk to its minimum size, it is expired and no longer draw.
- Anti alias options, useful if you don't want pixel graphics
- Border size and growth
- Set a random order, in which newly created blooms will be inserted randomly in the list.
- An experimental mask mode which was supposed to enable me to create those Missile Command style XOR drawing. However, it doesn't really work and I'll probably have another go at it at some point.
Room for improvement
Everything can be improved, one of the ideas I'd had for this tool was greater control over blooms, allowing you configure their locations etc with better precision but it wasn't necessary for the graphic I was creating. As mentioned above, the masking doesn't work as expected, it would have been nice if it did. Some better rendering would be a plus too, at the moment the "explosions" are simple rings of color. Some noise or other minor particle effects to make them a little less uniform would probably look interesting.
Source code, and optionally pre-compiled binaries, are available from the link below. The code has been compiled against the .NET 3.5 Client Profile. Due to some minor use of Linq and auto generated properties a small amount of work would be needed to compile against .NET 2.0. I'm afraid comments are somewhat lacking as well, I wasn't planning on releasing this publicly originally.
If anyone creates any interesting graphics or improves upon the code, we'd love to hear from you.
Sample C# application project which can generate simple arcade style explosion images for use in your own applications .
|05 June 2012||123.69 KB|
Pre-compiled binaries for the Arcade Explosion Generator sample project
|05 June 2012||134.21 KB|