#Constant Density = 100
Global ExCount as Integer
Type particles
   Speed as Float
   Emissive as DWord
Endtype
Dim PSet(0,Density) as particles
Null= Make Vector3(1)
 
Get_Fade_Image(1)
Get_Particle_Image(2)
 
 
Sync On: Sync Rate 60:Autocam Off
Color Backdrop 0
 
 
x0=rnd(60)-30:y0=rnd(60)-30:z0=rnd(30)+30
ax0=rnd(360):ay0=rnd(360):az0=rnd(360)
x1=rnd(60)-30:y1=rnd(60)-30:z1=rnd(30)+30
ax1=rnd(360):ay1=rnd(360):az1=rnd(360)
t=0
Do
   Set Cursor 0,0
   f0=Explosion(0,x0,y0,z0,ax0,ay0,az0)
   if t<60
      inc t
   Else
      f1=Explosion(2,x1,y1,z1,ax1,ay1,az1)
      t=1000
   Endif
   if f0=1
      x0=rnd(60)-30:y0=rnd(60)-30:z0=rnd(30)+30
      ax0=rnd(360):ay0=rnd(360):az0=rnd(360)
   Endif
   if f1=1
      x1=rnd(60)-30:y1=rnd(60)-30:z1=rnd(30)+30
      ax1=rnd(360):ay1=rnd(360):az1=rnd(360)
   Endif
   Sync
Loop
 
 
Function Explosion(ExID,x#,y#,z#,ax#,ay#,az#)
   fin=0
   If ExCount<ExID
      ExCount=ExID
      Dim PSet(ExCount,Density) as particles
   Endif
   if Object Exist(ExID*Density+2)=0 Then New_Explosion(ExID,x#,y#,z#,ax#,ay#,az#)
   for i = 1 to Density
      PID=ExID*Density+i+1
      If Object Exist(PID)
         Move Object PID,Pset(ExID,i).Speed
         r=RGBR(Pset(ExID,i).Emissive)
         g=RGBG(Pset(ExID,i).Emissive)
         b=RGBB(Pset(ExID,i).Emissive)
         dec r
         dec g
         dec b
         if r<0 then r=0
         if g<0 then g=0
         if b<0 then b=0
         Pset(ExID,i).Emissive=RGB(r,g,b)
         Set Object Emissive PID,Rgb(r,g,b)
         If i=1
            If r+g+b=0
               Delete Object PID
               fin=1
            Else
               Set Vector3 1,Object Position X(PID)-x#,Object Position Y(PID)-y#,Object Position Z(PID)-z#
               s#=Length Vector3(1)*180.0
               Scale Object ExID*Density+1,s#,s#,s#
            Endif
         Endif
      Endif
   Next i
Endfunction fin
 
 
 
Function New_Explosion(ExID,x#,y#,z#,ax#,ay#,az#)
   PID=ExID*Density+1
   If Object Exist(PID)=0
      Make Object Sphere PID,1,10,10
      Make Mesh From Object 1,PID
      For i = 1 to 5
         Add Limb PID,i,1
         Scale Limb PID,i,100-i*2,100-i*2,100-i*2
      Next i
      Texture Object PID,2
      Set ALpha Mapping On PID,30
      Set Object Emissive PID,Rgb(100,80,80)
      Set Object Cull PID,0
   Endif
   Rotate Object PID, rnd(360),rnd(360),rnd(360)
   Position Object PID,x#,y#,z#
   For i=1 to Density
      PID=ExID*Density+i+1
      If Object Exist(PID)=0
         Make Object Triangle PID, -.15,0,0, 0,0,-2, .15,0,0
         Make Mesh From Object 1,PID
         For j = 1 to 2
            Add Limb PID,j,1
            Offset Limb PID,j,rnd(30.0)/10.0-1.5,rnd(10.0)/20.0-.25,rnd(10.0)/20.0-.25
         Next j
         Texture Object PID,1
         Set Alpha Mapping On PID,80
      Endif
      Pset(ExID,i).Emissive=Rgb(rnd(200)+55,rnd(200)+55,rnd(200)+55)
      if i=1 Then Pset(ExID,i).Emissive=rgb(255,255,255)
      Set Object Emissive PID,Pset(ExID,i).Emissive
      Position Object PID,x#,y#,z#
      Rotate Object PID,ax#,ay#,az#
      Turn Object Right PID,Rnd(3600.0)/10.0
      Pitch Object Up PID,Rnd(200.0)/100.0-1.0
      Pset(ExID,i).Speed=.25
      Do
         if rnd(10)<7
            Pset(ExID,i).Speed=Pset(ExID,i).Speed-.005
         Else
            Exit
         Endif
      Loop
   Next i
Endfunction
 
Function Get_Fade_Image(Image)
   white as Dword
   white=Rgb(255,255,255)
   Box 0,0,32,32,0,White,0,White
   Get Image image,0,0,32,32,1
Endfunction
 
Function Get_Particle_Image(Image)
   Box 0,0,256,256,0,0,0,0
   For i = 1 to (256*256)/10
      Dot Rnd(512),Rnd(512),Rgb(rnd(100)+155,rnd(100)+155,rnd(100)+155)
   Next i
   Get Image Image,0,0,256,256,1
Endfunction