Draws a fire effect. Just a little code snippet I ported from my
8 year old snippet. Don't expect killer frame rates though :p
setVirtualResolution(320,240)
Type Color
r as integer
g as integer
b as integer
EndType
dim fire[320,240] as Color
global _Flame as float
_Flame = 4.12
c as Color
do
for y = 1 to 239
for x = 1 to 320
c = newValue(x, y)
fire[x,y] = c
drawLine(x,y,x,y+1, fire[x,y].r, fire[x,y].g, fire[x,y].b)
next x
next y
for x = 1 to 320
r = random(0, 255)
g = random(0,255)
if g > r then g = r
fire[x,240].r = r
fire[x,240].g = 0
fire[x,240].b = r
next x
if GetRawKeyState(38) = 1 then _Flame = _Flame + 0.02
if GetRawKeyState(40) = 1 then _Flame = _Flame - 0.02
print(_Flame)
sync()
loop
function newValue(x, y)
c as Color
c = getColor1(x,y+1)
r = c.r
g = c.g
b = c.b
c = getColor1(x-1,y+1)
r = r + c.r
g = g + c.g
b = b + c.b
c = getColor1(x+1,y+1)
r = r + c.r
g = g + c.g
b = b + c.b
c = getColor1(x,y+2)
r = r + c.r
g = g + c.g
b = b + c.b
c.r = r / _Flame
c.g = g / _Flame
c.b = b / _Flame
endfunction c
function getColor1(x, y)
c as Color
if x < 1 or x > 320 or y < 1 or y > 240
exitfunction c
endif
c = fire[x,y]
endfunction c
"You're all wrong. You're all idiots." ~Fluffy Rabbit