rem The Slinky Demo
rem coded by Christopher Rankine
rem On 9/7/02
rem Number of lines=45
rem Hi and thanks to Marc Gale and Nick Simpson

gosub setup
gosub loop
exit

label setup
 open window 640,512
 s=5
 springs=70
 timer=150
return

label loop
 repeat
  c=peek("port1")
  setdrawbuf d
  d=1-d
  setdispbuf d
  clear window
  gosub spring
 until (and(c,1)>0)
return

label spring
 if s>15 s=5
 mm=mm+0.5
 r=100*sin(mm)
 g=100*sin(mm/2)
 b=100*sin(mm/3)
 if r<20 and g<20 and b<20 r=100
 timer=timer-1
 if timer=0 then
  s=s+5
  timer=150
 fi
 l=200*sin(b/8)
 m=200*cos(b/7)
 for a=1 to springs
  x=320+l*sin((b+a)/s)
  y=250+m*sin((b+a)/20)
  setrgb 1,r,g,b
  circle x,y,50
 next a
 b=b+.05
return



