This fire image was mathematically generated using the code available below.
(NOTE: as of February 26th, 2009, version 2.0 of this code is available here.)
Whether working on an old-school RPG or a state-of-the-art FPS, every game programmer needs to be able to generate a fast, cool fire effect at some point in his/her career. In this example, I’ve opted for a straightforward and easy-to-understand method for generating real-time flames. No pre-built images or palettes are used, making the code quite small and easy to reuse. Coloring and flame generation is done using only math and a little cleverness. :)
To simplify the code, I’ve used SetPixelV for drawing the fire. This slows the demo down significantly, but DIB sections could easily be dropped into place if speed is a major factor for you.
DISCLAIMER: These download files are regularly scanned to ensure they remain free from malicious content. Unfortunately, some virus scanners will flag these .zip files as suspicious simply because they contain source code and/or executable files. I have submitted my projects to a number of companies in an attempt to rectify these false-positives. Some have been cooperative. Others have not. If your virus scanner alerts you regarding these files, please allow the file to be submitted for further analysis (if your program allows for that). This should help ensure that any false-positive warnings gradually disappear for all users.
This site - and its many free downloads - are 100% funded by donations. Please consider a small contribution to fund server costs and to help me support my family. Even $1.00 helps. Thank you!