I made this after we talked about constructive and destructive interference in physics class, out of wanting to see what it actually looked like in slow motion.
Just has two waves, one moving left and one right, and displays the result of the two waves using superposition.
Compressed:
sync on : sync rate 100 : set display mode 1024,768,screen depth()
DIM LeftWave(1024) : DIM RightWave(1024)
do : cls
if spacekey()=1 and go=0 : go=1 : pd=0 : endif
if shiftkey()=1 and go=0 : go=-1 : pd=0 : endif
for c=1023 to 0 step -1 : LeftWave(c+1)=LeftWave(c) : next c
for c=1 to 1024 : RightWave(c-1)=RightWave(c) : next c
if go<>0
inc pd
LeftWave(0)=(100*cos(pd)-100)
RightWave(1024)=(100*cos(pd)-100)*go
if pd=360 then go=0
endif
lock pixels
for ln=0 to 1024 : dot ln,LeftWave(ln)+RightWave(ln)+400 : next ln
unlock pixels
text 10,10,str$(screen fps()) : text 10,30,"Spacekey - Create constructive waves"
text 10,40,"Shiftkey - Create destructive waves" : text 20,50,"Hold to continually produce waves."
sync : loop
Uncompressed:
sync on : sync rate 100
set display mode 1024,768,screen depth()
DIM LeftWave(1024)
DIM RightWave(1024)
do
cls
if spacekey()=1 and go=0
go=1
pd=0
endif
if shiftkey()=1 and go=0
go=-1
pd=0
endif
for c=1023 to 0 step -1
LeftWave(c+1)=LeftWave(c)
next c
for c=1 to 1024
RightWave(c-1)=RightWave(c)
next c
if go<>0
inc pd
LeftWave(0)=(100*cos(pd)-100)
RightWave(1024)=(100*cos(pd)-100)*go
if pd=360 then go=0
endif
lock pixels
for ln=0 to 1024
dot ln,LeftWave(ln)+RightWave(ln)+400
next ln
unlock pixels
text 10,10,str$(screen fps())
text 10,30,"Spacekey - Create constructive waves"
text 10,40,"Shiftkey - Create destructive waves"
text 20,50,"Hold to continually produce waves."
sync
loop