open window 640,512
curbuf=0
x=320:y=256
setrgb 1,255,0,0
setrgb 2,255,0,0
setrgb 3,255,255,0
offset=0
size=30
speed=10

repeat
 setdrawbuf curbuf
 curbuf=1-curbuf
 setdispbuf curbuf
 clear window

 for x=0 to 640 step 40
  y=cos((x+offset)*(pi/180))*size+320
  gtriangle x-40,512 to x+40,512 to x,y
 next x

 offset=offset+speed
 if offset>360 then
  offset=offset-360
 fi

 joypad=peek("port1")
until (joypad=16384)
