- Tanner Helland (dot) Com - http://www.tannerhelland.com -
How to Use Math to Create Fire
Posted By Tanner On February 4, 2009 @ 1:10 am In Game Code,Gaming,Graphics Code,Programming | Comments Disabled
(NOTE: as of February 26th, 2009, version 2.0 of this code is available here [1].)
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 [2] if speed is a major factor for you.
Article printed from Tanner Helland (dot) Com: http://www.tannerhelland.com
URL to article: http://www.tannerhelland.com/535/mathematical-fire-code/
URLs in this post:
[1] here: http://www.tannerhelland.com/640/mathematical-fire-code-2/
[2] DIB sections could easily be dropped into place: http://www.tannerhelland.com/42/vb-graphics-programming-3/
Click here to print.
All text copyright © 2008 Tanner Helland. To reduce paper and ink usage, all comments, images, and videos have been suppressed on this printing.