fire

BlitzPlus Forums/BlitzPlus Programming/fire

YES i got it looking pritty good with nothing fancy :)

i actually think it looks ok now please check it out
Graphics 640,480

img = CreateImage(100,100)
SetBuffer ImageBuffer(img)
Color 255,0,0
Rect 50,98,10,2
SetBuffer BackBuffer()
frame = 0
While Not KeyDown(1)
SetBuffer ImageBuffer(img)
Color 255,0,0
Rect 50,98,10,2
SetBuffer BackBuffer()
Cls
LockBuffer ImageBuffer(img)
For x = 2 To 98
 	For y = 2 To 98
		top = ReadPixelFast(x,y-1,ImageBuffer(img))
		bot = ReadPixelFast(x,y+1,ImageBuffer(img))
		lleft = ReadPixelFast(x+1,y,ImageBuffer(img))
		rright = ReadPixelFast(x-1,y,ImageBuffer(img))
		If (GetRed(top)+GetRed(bot)+GetRed(lleft)+GetRed(rright))/4-2 > 0
		WritePixelFast x+Rand(-1,1),y-1,Combine((GetRed(top)+GetRed(bot)+GetRed(lleft)+GetRed(rright))/4-2,0,0),ImageBuffer(img)
		EndIf
	Next
Next
UnlockBuffer ImageBuffer(img)



frame = frame+1 Mod 5
		 
DrawImage img,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