i made this quite accidentaly and i was quite astonished over the results :
it simulates a "rope" that you can grab and stretch.
oh and as always it requires advanced 2d and perhaps matr1x utils
the cool thing is that the waves that form follow the laws of physics!
when they reach the end of the rope, which is locked to a wall, it will not only bounce back but also it will inverse itself! which is what happens in real life. quite useless but cool. not sure how it will work on other computers as it requires a quite high framerate to look good and work like it should. i have restricted it to 1000 fps but it runs 2500 on my comp with theese settings.
sync on : sync rate 5000
w = screen width() : h = screen height() : a =100 : var = (w-100)/a
dim x#(a) : dim y#(a) : dim v(a) : dim m#(a)
for i = 1 to a : x#(i) = i*var : y#(i) = rnd(10)+h/2 : m#(i) = 10 : v(i) = createvector(): NEXT
F1 = createvector() : F2 = createvector() : G = createvector()
a2setblendmode 2,2,1
speed# = 5000
rad = 5 : basefriction# = 1-2/speed# : lineforce# = 0.002
do
mx# = mousex() : my# = mousey() : if mouseclick() = 0 then selected = 0
x#(1) = 50 : y#(1) = h/2 : x#(a) = w-50 : y#(a) = h/2
if spacekey() then friction# = 0 else friction# = basefriction#
for i = 2 to a-1
set vector2 F1,x#(i-1)-x#(i),y#(i-1)-y#(i) : set vector2 F2,x#(i+1)-x#(i),y#(i+1)-y#(i) : set vector2 G,0,0.01*m#(i)
add vector2 F1,F1,F2 : add vector2 F1,F1,G : multiply vector2 F1,lineforce#
add vector2 v(i),v(i),F1 : multiply vector2 v(i),friction#
NEXT
for i = 1 to a
x#(i) = x#(i)+x vector2(v(i)) : y#(i) = y#(i)+y vector2(v(i))
if selected = i then x#(i) = mx# : y#(i) = my# : set vector2 v(i),0,0
if button(x#(i)-rad,y#(i)-rad,x#(i)+rad,y#(i)+rad) = 2 and selected = 0 then selected = i : m#(i) = 1
if button(x#(i)-rad,y#(i)-rad,x#(i)+rad,y#(i)+rad) = 3 and selected = 0 then m#(i) = 1000
NEXT
a2startlinebatch a-1 : for i = 2 to a : a2line x#(i-1),y#(i-1),x#(i),y#(i),rgb(100,100,200)
if m#(i) > 10 then a2circle x#(i),y#(i),2,rgb(255,0,0)
next : a2endbatch
sync : cls
LOOP
function lenvec(vec,len#)
normalize vector2 vec,vec : multiply vector2 vec,len#
ENDFUNCTION
function createvector()
num = find free vector() : null = make vector2(num)
ENDFUNCTION num
function button(x1,y1,x2,y2)
if mousex() > x1 and mousex() < x2 and mousey() > y1 and mousey() < y2
selected = mouseclick()+1
endif
endfunction selected
haha! remembered the code!