This content has moved - please find it at https://devblog.cyotek.com.

Although these pages remain accessible, some content may not display correctly in future as the new blog evolves.

Visit https://devblog.cyotek.com.

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!

A screenshot from Missile Command

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.

A sample of the default output

Another sample using some custom settings

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.

Application Features

  • Configuration settings can be saved and reloaded for tweaking of favoured settings. Uses basic Reflection serialization as XmlSerializer can'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
  • The TrackBar control embedded in the ToolStrip is a custom component inheriting from ToolStripControlHost which can be reused. And once you understand the principles, it's so easy to host other controls.

Graphic Settings

  • 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 blooms
  • 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.

An example generated by the project

Another example of generated output

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

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.

Update History

  • 2012-06-03 - First published
  • 2020-11-21 - Updated formatting

Downloads

Filename Description Version Release Date
Cyotek.ArcadeExplosionMaker.zip
  • md5: bd412009442f7923a555ba5b0f508fe0

Sample C# application project which can generate simple arcade style explosion images for use in your own applications .

1.0.0.1 05/06/2012 Download
Cyotek.ArcadeExplosionMaker.Bin.zip
  • md5: 95d450cb7c4d2de25bfe03b105e7adc2

Pre-compiled binaries for the Arcade Explosion Generator sample project

1.0.0.1 05/06/2012 Download

About The Author

Gravatar

The founder of Cyotek, Richard enjoys creating new blog content for the site. Much more though, he likes to develop programs, and can often found writing reams of code. A long term gamer, he has aspirations in one day creating an epic video game. Until that time, he is mostly content with adding new bugs to WebCopy and the other Cyotek products.

Leave a Comment

While we appreciate comments from our users, please follow our posting guidelines. Have you tried the Cyotek Forums for support from Cyotek and the community?

Styling with Markdown is supported