hide mouse
 
parts=1500
 
dim partvel#(parts)  : rem Velocity
dim partlife(parts) : rem Life
dim partmlife(parts): rem Max Life
 
set text size 40
center text 320,50,"Proccessing "+str$(parts)+" particles!"
sync on
sync
 
for i=1 to parts
   make object plain i+10,5,5
   scale object i+10,rnd(300)+100,rnd(300)+100,rnd(300)+100
   rotate object i+10,rnd(360),rnd(360),rnd(360)
   fix object pivot i+10
next i
 
backdrop on
color backdrop 0
autocam off
 
make object sphere 1,1
color object 1,rgb(255,128,0)
ghost object on 1
disable object zdepth 1
 
make object plain 2,1,1
color object 2,rgb(255,128,0)
make mesh from object 1,2
 
limb=0
for j=1 to 7
   x=0
   y=0
   z=0
   for i=1 to 50
      limb=limb+1
      x=x+(rnd(2)-1)
      y=y+(rnd(2)-1)
      z=z+(rnd(2)-1)
      add limb 2,limb,1
      rotate limb 2,limb,rnd(360),rnd(360),rnd(360)
      offset limb 2,limb,x,y,z
      color limb 2,limb,rgb(255,128,0)
   next i
next j
 
x#=rnd(640)
y#=rnd(50)-500
z#=rnd(480)
Create Explosion(x#,y#,z#,parts)
spheresize#=100
sphereacc#=30
 
flyingobjmomentumx#=rnd(360)
flyingobjmomentumy#=rnd(360)
flyingobjmomentumz#=rnd(360)
flyingobjspeed=100
flyingobjtrav=0
 
position camera 320,400,240
xrotate camera 90
 
do
 
   gosub HandleExplosion
 
   sync
 
loop
 
HandleExplosion:
 
   for i=1 to parts
 
      partlife(i)=partlife(i)-1
      if partlife(i)<=50
         x#=rnd(640)
         y#=rnd(50)-500
         z#=rnd(480)
         Create Explosion(x#,y#,z#,parts)
         spheresize#=100
         sphereacc#=30
         flyingobjmomentumx#=rnd(360)
         flyingobjmomentumy#=rnd(360)
         flyingobjmomentumz#=rnd(360)
         flyingobjspeed=100
         flyingobjtrav=0
      endif
 
      partvel#(i)=partvel#(i)*1.1
 
      move object i+10,partvel#(i)
      life#=partlife(i)
      mlife#=partmlife(i)
      green#=200-(life#*0.3/mlife#*200)
      if green#>200 then green#=200
      if green#<0 then green#=0
      lum#=(life#*3.0/mlife#*255)
      if lum#>255 then lum#=255
      if lum#<1 then lum#=1
      red#=255
      color object i+10,rgb(red#,green#,0)
 
   next i
 
   sphereacc#=sphereacc#*1.1
   spheresize#=spheresize#+15000
   scale object 1,spheresize#,spheresize#,spheresize#
   lum#=100-spheresize#/4000
   if lum#<0 then hide object 1
   red#=255-100/lum#*255
   green#=255-100/lum#*128
   color object 1,rgb(red#,green#,0)
 
   rotate object 2,flyingobjmomentumx#,flyingobjmomentumy#,flyingobjmomentumz#
   position object 2,newxvalue(x#,flyingobjmomentumx#,flyingobjtrav),newyvalue(y#,flyingobjmomentumy#,flyingobjtrav),newzvalue(z#,flyingobjmomentumz#,flyingobjtrav)
   flyingobjtrav=flyingobjtrav+flyingobjspeed
   if object position y(2)>400 then hide object 2
   flyingobjangx#=wrapvalue(flyingobjangx#+20)
   flyingobjangy#=wrapvalue(flyingobjangy#+20)
   flyingobjangz#=wrapvalue(flyingobjangz#+20)
   rotate object 2,flyingobjangx#,flyingobjangy#,flyingobjangz#
 
return
 
end
 
function Create Explosion(x#,y#,z#,parts)
 
   for i=1 to parts
      ax#=rnd(360)
      ay#=rnd(360)
      az#=rnd(360)
      partvel#(i)=rnd(40)+10
      partlife(i)=rnd(10)+100
      partmlife(i)=100
      position object i+10,x#,y#,z#
      rotate object i+10,ax#,ay#,az#
      color object i+10,rgb(255,0,0)
   next i
   position object 1,x#,y#,z#
   scale object 1,100,100,100
   show object 1
 
   position object 2,x#,y#,z#
   show object 2
 
endfunction