Good Fire?

Blitz3D Forums/Blitz3D Beginners Area/Good Fire?

I was wondering if this was a good fire effect. It didn't take me long to do, but I would like some feedback from the community.

IMG


You are allowed to use the code and image if you like it but please put me in the credits or in any source code released.

Graphics3D 640,480,32,2
SetBuffer BackBuffer()
SeedRnd MilliSecs()

Global halfwidth=640/2
Global halfheight=480/2

Type flame
	Field x,y
	Field size
	Field alpha#
	Field src
	Field rot
	Field angle
	Field speed
	Field fadespeed#
	Field rotright
End Type

Global f.flame

Global camera=CreateCamera(),light=CreateLight()

Global flamesprite=LoadSprite("flame.bmp",1):HideEntity flamesprite

Global fps=CreateTimer(60)

For i=1 To 10
	CreateFlame(halfwidth,halfheight+50)
Next

While Not KeyHit(1)
	Flip:RenderWorld
	
	WaitTimer(fps)
	
	UpdateFlame()
	
Wend
End

Function CreateFlame(x,y)
	f.flame=New flame
	f\x=x
	f\y=y
	f\size=Rand(50,100)/2
	f\alpha=1
	f\src=CopyEntity(flamesprite)
	f\rot=Rand(360)
	f\speed=Rand(1,3)
	f\angle=Rand(-40,40)
	f\fadespeed=Rnd(0.01,0.04)
	f\rotright=Rand(1,2)
	ScaleSprite f\src,f\size,f\size
End Function

Function UpdateFlame()
	For f.flame=Each flame
		If f\alpha > 0
			f\alpha=f\alpha-f\fadespeed
			If f\rotright=1
				f\rot=f\rot+6
			ElseIf f\rotright=2
				f\rot=f\rot-6
			EndIf
			f\y=f\y-f\speed
			;f\x=f\x+Sin(f\angle)*f\speed
			RotateSprite f\src,f\rot
			PositionEntity f\src,f\x-halfwidth,halfheight-f\y,halfwidth*1
			EntityAlpha f\src,f\alpha
		Else
			FreeEntity f\src
			Delete f
			CreateFlame(halfwidth,halfheight+50)
		EndIf
	Next
End Function


nice. I like it!

Could a mod move this to Graphics Showcase, please?

Thanks

can´t move forum things to the archives. Please copy paste. Thanks for sharing, will try this asap.

Nice tho mostly "torch-only" fire. FOr the rotation: how about an additional random flag for left vs right rotation?

I modified the code so that it has the random flag for rotating left or right.

Hey, jfk EO-11110! Did you notice what piece of code I used to get the 2D screen co-ords? I must say that I use that all the time now. It's very useful. Now I can make 2D games with alpha and transparency effects!

3D emulated 2D rules. Not only alpha, but also add-blendmode for shiny magic fx, as well as smooth "antialiased" contours are possible this way.