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. :)
As usual, the sample code was written for VB6, but an .exe is included for those just wanting screenshots (or if you just want to see the effect in action). 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.
Print This Article
Discussion (Oldest Comments Displayed First)
Comments are closed.