***UPDATE: Still needs help please (see 3 posts down)
Hi,
I am using this code for the animated dragon with fire (based on the demo script - modified slightly to incorporate it in to the game engine that I am using - the engine code calls the 'TestDragonFire' function):
========
Type fire
Field x#
Field y#
Field z#
Field alpha#
Field entity
Field scale#
End Type
Function TestDragonFire(DragonX#, DragonY#, DragonZ#)
SetBuffer BackBuffer()
enable=True
vert=False
dragon = LoadMD2 ("C:\blitz3d\Blitz3D\samples\dragon\model\dragon.md2 ")
tex = LoadTexture("C:\blitz3d\Blitz3D\samples\dragon\model\dragon.bmp")
PositionEntity dragon,DragonX#,DragonY#,DragonZ#
EntityTexture dragon,tex
AnimateMD2 dragon,1,0.05,90,130
;--------------- fire--------------------
pivFire=CreatePivot()
sprite = LoadSprite("C:\blitz3D\Blitz3D\samples\dragon\Fire.bmp ",2,pivFire)
PositionEntity sprite,3,20,43,False
RotateEntity sprite,0,90,0,False
HideEntity sprite
con#=0.5:conx#=0.3:no=5
Md=4
;----------------------------------------
time=MilliSecs()
;-------------- mod of fire------
If Md=1 Then
a1=117:b1=122
con#=1:conx#=0.8:no=5
PositionEntity sprite,3,20,43,False
RotateEntity sprite,0,90,0,False
End If
If Md=2 Then
a1=125 :b1=127
con#=0.4:conx#=0.4:no=1
PositionEntity sprite,-18,10,23,False
End If
If Md=3 Then
a1=100 :b1=102
con#=0.4:conx#=0.3:no=3
PositionEntity sprite,-3,3,33,False
End If
If Md=4 Then
a1=90 :b1=93
con#=1:conx#=1:no=7
PositionEntity sprite,10,15,43,False
RotateEntity sprite,0,75,0,False
End If
;--------------- fire --------------------
u=u+1
If u>360 Then u=1
Repeat
elapsed=MilliSecs()-time
Until elapsed>0
time=time+elapsed
dt#=elapsed*60.0/1000.0
anim=MD2AnimTime(dragon)
If anim>129 Then
Md=4
End If
If anim>93 And anim<100 Then
Md=3
End If
If anim>100 And anim<122 Then
Md=1
End If
If anim>122 And anim<127 Then
Md=2
End If
If anim>a1 And anim<b1
For i=1 To no
f.fire=New fire
f\alpha#=1;Rnd(0,1)
f\scale#=con#*Rnd(8,12)
f\entity=CopyEntity (sprite,piv1)
SpriteViewMode f\entity,1
RotateSprite f\entity,Rnd(360)
num=mum+1
Next
End If
For f.fire=Each fire
f\alpha#=f\alpha#-0.02
;f\scale#=f\scale#-Rnd(0.02,0.1)
If f\alpha>0
EntityAlpha f\entity,f\alpha
If f\alpha#<0.4Then
EntityColor f\entity,80,200,150
f\x#=con#*conx#*3
f\y#=con#*Rnd(2.4,6.4)
f\z#=con#*Rnd(-4.8,4.8)
ElseIf f\alpha#<0.8 And f\alpha#>0.4Then
f\scale#=con#*Rnd(10,14)
f\x#=con#*conx#*4;Rnd(1.9,2)
f\y#=con#*Rnd(-6,6)
f\z#=con#*Rnd(-6,6)
Else
f\scale#=con#*4
f\x#=con#*conx#*Rnd(2,4)
f\y#=con#*Rnd(-2,2)
f\z#=con#*Rnd(-2,2)
EndIf
ScaleSprite f\entity,f\scale#,f\scale#
MoveEntity f\entity,f\x,f\y,f\z
EntityBlend f\entity, 3
Else
FreeEntity f\entity
Delete f
num=num-1
EndIf
Next
;--------------------------------------------
Flip
End Function
======
The dragon appears in-game and animates ok but no fire particles appear.
I'm new to blitz and I fear I may have edited something without realising that is stopping them.
I would appreciate if someone could check the above to see if it is going wrong somewhere.
Many Thanks!
Hi,
I am using this code for the animated dragon with fire (based on the demo script - modified slightly to incorporate it in to the game engine that I am using - the engine code calls the 'TestDragonFire' function):
========
Type fire
Field x#
Field y#
Field z#
Field alpha#
Field entity
Field scale#
End Type
Function TestDragonFire(DragonX#, DragonY#, DragonZ#)
SetBuffer BackBuffer()
enable=True
vert=False
dragon = LoadMD2 ("C:\blitz3d\Blitz3D\samples\dragon\model\dragon.md2 ")
tex = LoadTexture("C:\blitz3d\Blitz3D\samples\dragon\model\dragon.bmp")
PositionEntity dragon,DragonX#,DragonY#,DragonZ#
EntityTexture dragon,tex
AnimateMD2 dragon,1,0.05,90,130
;--------------- fire--------------------
pivFire=CreatePivot()
sprite = LoadSprite("C:\blitz3D\Blitz3D\samples\dragon\Fire.bmp ",2,pivFire)
PositionEntity sprite,3,20,43,False
RotateEntity sprite,0,90,0,False
HideEntity sprite
con#=0.5:conx#=0.3:no=5
Md=4
;----------------------------------------
time=MilliSecs()
;-------------- mod of fire------
If Md=1 Then
a1=117:b1=122
con#=1:conx#=0.8:no=5
PositionEntity sprite,3,20,43,False
RotateEntity sprite,0,90,0,False
End If
If Md=2 Then
a1=125 :b1=127
con#=0.4:conx#=0.4:no=1
PositionEntity sprite,-18,10,23,False
End If
If Md=3 Then
a1=100 :b1=102
con#=0.4:conx#=0.3:no=3
PositionEntity sprite,-3,3,33,False
End If
If Md=4 Then
a1=90 :b1=93
con#=1:conx#=1:no=7
PositionEntity sprite,10,15,43,False
RotateEntity sprite,0,75,0,False
End If
;--------------- fire --------------------
u=u+1
If u>360 Then u=1
Repeat
elapsed=MilliSecs()-time
Until elapsed>0
time=time+elapsed
dt#=elapsed*60.0/1000.0
anim=MD2AnimTime(dragon)
If anim>129 Then
Md=4
End If
If anim>93 And anim<100 Then
Md=3
End If
If anim>100 And anim<122 Then
Md=1
End If
If anim>122 And anim<127 Then
Md=2
End If
If anim>a1 And anim<b1
For i=1 To no
f.fire=New fire
f\alpha#=1;Rnd(0,1)
f\scale#=con#*Rnd(8,12)
f\entity=CopyEntity (sprite,piv1)
SpriteViewMode f\entity,1
RotateSprite f\entity,Rnd(360)
num=mum+1
Next
End If
For f.fire=Each fire
f\alpha#=f\alpha#-0.02
;f\scale#=f\scale#-Rnd(0.02,0.1)
If f\alpha>0
EntityAlpha f\entity,f\alpha
If f\alpha#<0.4Then
EntityColor f\entity,80,200,150
f\x#=con#*conx#*3
f\y#=con#*Rnd(2.4,6.4)
f\z#=con#*Rnd(-4.8,4.8)
ElseIf f\alpha#<0.8 And f\alpha#>0.4Then
f\scale#=con#*Rnd(10,14)
f\x#=con#*conx#*4;Rnd(1.9,2)
f\y#=con#*Rnd(-6,6)
f\z#=con#*Rnd(-6,6)
Else
f\scale#=con#*4
f\x#=con#*conx#*Rnd(2,4)
f\y#=con#*Rnd(-2,2)
f\z#=con#*Rnd(-2,2)
EndIf
ScaleSprite f\entity,f\scale#,f\scale#
MoveEntity f\entity,f\x,f\y,f\z
EntityBlend f\entity, 3
Else
FreeEntity f\entity
Delete f
num=num-1
EndIf
Next
;--------------------------------------------
Flip
End Function
======
The dragon appears in-game and animates ok but no fire particles appear.
I'm new to blitz and I fear I may have edited something without realising that is stopping them.
I would appreciate if someone could check the above to see if it is going wrong somewhere.
Many Thanks!