aUCBLogo Demos and Tests / explosion_video
to explosion_video
setUpdateGraph false
perspective
setEye {0 0 600}{0 0 0}{0 1 0}
clearScreen
disdt
ht
t0=5
t=t0
t1=20
radius=80
maxlevel=4
ex=Array 1000
VideoStart "test
until [or Key? t>1000]
[ cs
(reRandom 0)
explode radius*(1-exp -t/t1) exp -t/t1 maxlevel
updateGraph
setXYZ -4*radius -4*radius 0
ex.t=BitCopy 8*radius 8*radius
home
t=t+1
VideoFrame
]
VideoEnd
if Key? [ignore readChar]
pr t
tend=t
setXYZ -4*radius -4*radius 0
until [Key?]
[ for [t t0 tend-1]
[ BitPaste ex.t
updateGraph
]
waitms 1000
]
(GC true)
end
to explode r a level
setPC hsba 0 1-(norm PosXYZ)/(4*radius) 0.7 a
sphere r
local [ori p r2 i]
ori=Orientation
p=PosXYZ
if level > 1
[ for [i 1 12]
[ rightRoll 360*rnd
up 180*rnd
r2=r*(1-0.1*rnd)
pu
fd r2
if r > 0
[ explode r2*(1-exp -t/t1*r2/r) a*sqr r2/r level-1
]
setPosXYZ p
setOrientation ori
]
]
end