aUCBLogo Demos and Tests / bouncingparticles2
be bouncingparticles2
part 1000 4
end
be part partnum :pensize
intrepeat=10000
partx=(array partnum 1)
partv=array partx
parta=array partx
partcolor=array partx
partbounces=array partx
trails=true
setUpdateGraph false
setPointSize :pensize
disableDepthTest
disablePointSmooth
; enablePointSmooth
cs ht pu setpc [50 230 20]
setx 0 sety -200 - :pensize
pd rt 90 fd 1000 pu home pd
OnMouseLeftDown [trails=true]
OnMouseRightDown
[ cs ht pu setpc [50 230 20]
setx 0 sety -200 - :pensize
pd rt 90 fd 1000 pu home pd
trails=false
]
repeat partnum
[ j=repcount
partx.j=Float List 0 0
partv.j=List rnd-0.5 (rnd+1)
parta.j=List 0.0 -0.01
partbounces.j=Int 0
partcolor.j=HSB 360*j/(partnum+1) 1 1
]
norefresh
white2=RGBA 1 1 1 0.05
forever
[ ifelse trails
[ Home
setFC white2
FillRect [-400 -300][400 300]
][ clearScreen
]
partx+=partv
partv+=parta
repeat partnum
[ if partx.repcount.2 < -200
[ j=repcount
partx.j.2=-199.99
partv.j.2=-partv.j.2/1.5
partbounces.j=partbounces.j+1
if partbounces.j==10
[ partx.j=Float List 0 0
partv.j=List rnd-0.5 (rnd+1)
partbounces.j=Int 0
]
]
]
setPixel partx partcolor
if Key? [break]
updateGraph
]
end