set display mode 1024,768,32 sync on sync rate 60 color backdrop 0 hide light 0 autocam off sw#=screen width() sh#=screen height() k#=0.045 d#=0.85 g#=0.0005 m#=70.0 maxv#=2.0 s#=50 beads=22 dim x#(beads) dim y#(beads) dim vx#(beads) dim vy#(beads) create bitmap 1,sw#,sh# make object sphere 1,10,50,50 set object diffuse 1,rgb(100,100,255) position object 1,0,0,20 make light 1 set light range 1,30 sync get image 2,0,0,sw#,sh#,1 delete object 1 sprite 1,0,0,2 size sprite 1,s#,s# paste sprite 1,0,0 get image 1,0,0,s#,s#,1 delete bitmap 1 delete image 2 delete sprite 1 set camera to image 0,100,256,256 sprite 100,0,0,100 size sprite 100,sw#,sh# set sprite 100,0,1 set sprite alpha 100,2 set sprite priority 100,1 position mouse sw#/2.0,sh#/2.0 for n=1 to beads x#(n)=sw#/2.0 y#(n)=sh#/2.0 next n st=timer() do t#=timer() dtl#=t#-ot# ot#=t# inc dtt#,dtl# inc l# if l#=10 then l#=0 if l#=0 then dt#=dtt#/10.0:dtt#=0 x#(1)=mousex() y#(1)=mousey() for n=2 to beads dx1#=x#(n)-x#(n-1) if n<beads dx2#=x#(n+1)-x#(n) else dx2#=0 endif dy1#=y#(n)-y#(n-1) if n<beads dy2#=y#(n+1)-y#(n) else dy2#=0 endif if n=2 dx1#=dx1#*5 dy1#=dy1#*5 endif ex#=dx2#-dx1# ey#=dy2#-dy1# fx#=k#*ex# fy#=(k#*ey#)+(m#*g#) ax#=fx#/m# ay#=fy#/m# inc vx#(n),ax#*dt# if vx#(n)>maxv# then vx#(n)=maxv# if vx#(n)<-maxv# then vx#(n)=-maxv# vx#(n)=vx#(n)*d# inc vy#(n),ay#*dt# if vy#(n)>maxv# then vy#(n)=maxv# if vy#(n)<-maxv# then vy#(n)=-maxv# vy#(n)=vy#(n)*d# if x#(n)>sw#-s# then x#(n)=sw#-s#-vx#(n) if x#(n)<0 then x#(n)=1+vx#(n) inc x#(n),vx#(n)*dt# if y#(n)>sh#-s# then y#(n)=sh#-s#-vy#(n) if y#(n)<0 then y#(n)=0 inc y#(n),vy#(n)*dt# if c#<100 then y#(n)=sh#/2.0 sprite n,x#(n),y#(n),1 next n inc c# sync loop