here it is! before loop: YMAX=224:XMAX=384 In loop: IF Y<0 THEN Y=0 IF Y>YMAX THEN Y=YMAX IF X<0 THEN X=0 IF X>XMAX THEN X=XMAX that should work :D