open window 640,512
curbuf=0
x=0:xd=4

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

 setrgb 1,255,0,0
 setrgb 2,255,0,0
 setrgb 3,255,255,0
 gtriangle 0,0 to 0,512 to x,0
 gtriangle 640,0 to 640,512 to x,0
 setrgb 2,255,255,0
 gtriangle 0,512 to x,0 to x,512
 gtriangle 640,512 to x,512 to x,0

 x=x+xd
 if x>640 or x<0 then
  xd=-xd
 fi

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