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
|