REM *********************************************** REM Title: Springs REM Author: Phaelax REM Downloaded from: http://dbcc.zimnox.com/ REM *********************************************** x# = 150.0 :` starting position m# = 8.0 :` mass R# = 150 :` resting length K# = 0.6 :` spring coefficient v# = 0.0 :` velocity f# = 0.9 :` friction backdrop on color backdrop 0 sync on sync rate 60 coils = 18 dim points(coils,1) repeat if mousex() > x#-10 and mousex() < x#+10 and flag = 0 and mouseclick() mx# = mousex() - x# flag = 1 endif if flag = 1 and mouseclick() x# = mousex() - mx# else flag = 0 force# = -k# * (x#-R#) v# = (v# + force#/m#)*f# x# = x# + v# endif ink rgb(120,120,0),0 box R#-10,230,R#+10,250 ink rgb(255,255,255),0 box x#-10,230,x#+10,250 rem draw spring h# = (R#/x#)*20 if h# > 20 then h# = 20 offset = x#/coils for t = 1 to coils if t mod 2 = 0 y = h# else y = -h# endif points(t,0) = offset*t points(t,1) = 240+y next t line 0,240,points(1,0),points(1,1) line points(coils,0),points(coils,1),x#,240 for i = 1 to coils-1 line points(i,0),points(i,1),points(i+1,0),points(i+1,1) next i rem end draw spring set cursor 0,0 print "force: ",force# print "pos: ",x# sync until spacekey() end