Snow, fire and bubbles.
Blitz3D Forums/Blitz3D Programming/Snow, fire and bubbles.
| ||
Hi, The code to create snow, fire and bubbles is interesting. I cannot figure out how to control it though. I cannot link the snow to the camera (parent/child) so it is allways snowing at the camera. code below. Any input of type coding would help. I'll try to find the tutorials on it. Gerald Global flame04=CreateSprite("gameart\base4.bmp"):HideEntity flame04 ;Global flame02=LoadSprite("gameart\base2.bmp"):HideEntity flame02 ;Global flame02=CreateCone(8,piv):HideEntity flame02 Global flame03=CreateSprite("gameart\base3.bmp"):HideEntity flame03 Global flame02=CreateSphere(piv):HideEntity flame02 - - - - - tfire2.fire2=Add_Fire2(0,0,0) - - - se = 10 main loop - - - tfire2.fire2=Add_Fire2(0,-23,300) Update_Fires2() Add_flame2(0,-23,300) Add_Fire2(0,-23,300) - - - Update_Fires2() - - - se = se + 1 If se >= 10 Then HideEntity flame02 ;Erase_Fires2 ;HideEntity tfire2\piv2 ;erase_Flames2 HideEntity Exp1 TranslateEntity tfire2\piv2,0,-50,0 End If - - - - - ;in collision loop - - PositionEntity tfire2\piv2,CollisionX#(bullet(q),1),CollisionY#(bullet(q),1),CollisionZ#(bullet(q),1) ;PositionEntity Exp1,CollisionX#(bullet(q),1),CollisionY#(bullet(q),1),CollisionZ#(bullet(q),1) ;ShowEntity Exp1 ShowEntity tfire2\piv2 se = 0 - - - ;subroutines near end of code file - . .stwof2 .stwof2 ;flame02=LoadSprite("gameart\base2.bmp");:HideEntity flame02 ;flame02=CreateCone(8,piv2):HideEntity flame02 flame02=CreateSphere(8,camera):HideEntity flame02 ;Each Flame of the fire Type flame2 Field ent2 Field ang2# Field size2# Field piv2;mine Field alph2# Field dis2# Field dx2#, dy2#, dz2# End Type ;The fire itself Type fire2 ;Field piv2 Field piv2 ; Direction Field dx2#, dy2#, dz2# End Type ;Add a fire to the scene Function Add_Fire2.fire2(x2#,y2#,z2#,dx2#=1,dy2#=.23,dz2#=1) a2.fire2=New fire2 a2\piv2=CreatePivot() ;a2\piv2=CreatePivot(camera) PositionEntity a2\piv2,x2,y2,z2 a2\dx2=dx2:a2\dy2=dy2:a2\dz2=dz2 Return a2 End Function ;Add a flame to the fire Function Add_flame2(x2#,y2#,z2#,size2#=1,dis2#=.016,dx2#=1,dy2#=0.3,dz2#=1) a2.flame2=New flame2 ;flame02=LoadSprite("gameart\base2.bmp"):HideEntity flame02 ;flame02=CreateCone(8,piv2);:HideEntity flame02 ;a2\ent2=CreateCone(8,piv2);:HideEntity flame02 flame02=CreateSphere(8,camera):HideEntity flame02 a2\ent2=CreateSphere(8,camera):HideEntity flame02 a2\ent2=CopyEntity(flame02) PositionEntity a2\ent2,x2,y2,z2 a2\alph2=1 a2\size2=size2 a2\dis2=dis2 a2\ang2=Rnd(360) ScaleEntity a2\ent2,a2\size2,a2\size2,a2\size2 ;ScaleSprite a2\ent2,a2\size2,a2\size2;,a2\size2 ;EntityColor a2\ent2,Rnd(100,255),Rnd(0,200),0 EntityColor a2\ent2,250,250,250 a2\dx2=dx2 a2\dy2=dy2 a2\dz2=dz2 End Function ;Update flames Function Update_flames2() For a2.flame2=Each flame2 If a2\alph2>0.01 Then a2\alph2=a2\alph2-a2\dis2 EntityAlpha a2\ent2,a2\alph2 RotateEntity a2\ent2,a2\ang2,a2\ang2=a2\ang2+.2,a2\ang2 ;RotateSprite a2\ent2,a2\ang2 ;a2\ang2=a2\ang2+.2;,a2\ang2 MoveEntity a2\ent2,-a2\dx2,-a2\dy2,-a2\dz2 ;Movesprite a2\ent2,a2\dx2,a2\dy2,a2\dz2 Else FreeEntity a2\ent2 Delete a2 End If Next End Function ;Erase all flames Function erase_Flames2() For a2.flame2=Each flame2 If a2\ent2<>0 Then FreeEntity a2\ent2 Next Delete Each flame2 End Function ;Update all fires Function Update_Fires2() For a2.fire2=Each fire2 Add_flame2(EntityX(a2\piv2),EntityY(a2\piv2),EntityZ(a2\piv2),Rnd(1,4),.04,a2\dx2,a2\dy2,a2\dz2) Next Update_Flames2() End Function ;Erase all fires Function Erase_Fires2() For a2.fire2=Each fire2 If a2\piv2<>0 Then FreeEntity a2\piv2 Next Delete Each fire2 End Function Return |