fire

BlitzPlus Forums/BlitzPlus Programming/fire

here is a little fire thing i made, it doesnt work amasingly well but im gunna make it into a set of functions but wanted people just to tell me it this is something they think i should work on :)

Graphics 640,480

Global i = CreateImage(100,100)
Dim cooling(100,100)
For x = 0 To 100
For y = 0 To 100
	cooling(x,y)=3
Next
Next 
cooling(50,80) = 4

SetBuffer ImageBuffer(i)
Color 255,0,0
Rect 50,97,10,3
SetBuffer BackBuffer()

While Not KeyDown(1)
SetBuffer ImageBuffer(i)
Color 255,0,0
Rect 50,97,10,3
SetBuffer BackBuffer()
LockBuffer ImageBuffer(i)
For x = 2 To 98
 	For y = 2 To 98
		top = ReadPixelFast(x,y-1,ImageBuffer(i))
		bot = ReadPixelFast(x,y+1,ImageBuffer(i))
		lleft = ReadPixelFast(x+1,y,ImageBuffer(i))
		rright = ReadPixelFast(x-1,y,ImageBuffer(i))
		If GetRed(top)+GetRed(bot)+GetRed(lleft)+GetRed(rright)
		WritePixelFast x,y-1,Combine((GetRed(top)+GetRed(bot)+GetRed(lleft)+GetRed(rright))/4-cooling(x,y),0,0),ImageBuffer(i)
		EndIf
	Next
Next
UnlockBuffer ImageBuffer(i)
DrawImage i,0,0
Flip
Wend
		
		
		
		
		
		
Function GetRed(col)	
Return (col Shr 16) And $FF 
End Function 
Function GetGreen(col)
Return  (col Shr 8) And $FF
End Function 
Function GetBlue(col)
Return col And $FF 
End Function 

Function Combine(r,g,b)
Return (b Or (g Shl 8) Or (r Shl 16) Or (255 Shl 24)) 
End Function