fun with a worm. directionally, rather than positionally based const qlength=20,unknown=0,north=1,east=2,south=3,west=4; var qx{qlength},qy{qlength},tail,head,current,lastx,lasty,newx,newy; procedure direction; var x,y; begin current:=unknown; if cvx>-1 then begin x:=cvx-250; y:=150-cvy; if -xy then current:=east end; if -x>y then begin if x>y then current:=south; if x-1 do begin call cvclear; call cvline(100,0,400,300); call cvline(100,300,400,0); call direction; if current#unknown then begin newx:=lastx; newy:=lasty; if current=north then newy:=lasty-10; if current=east then newx:=lastx+10; if current=south then newy:=lasty+10; if current=west then newx:=lastx-10; if newx>0 then if newx<500 then if newy>0 then if newy<300 then begin lastx:=newx; lasty:=newy; call enqueue(lastx,lasty) end end; call draw; call wait(200) end end end.