if bgget(L,dx+8,dy+17,1)==-1 then dy=1 spofs 0,sx+dx,sy+dy とかどうですか