Let's say VAR BOXX1=50,BOXY1=50 VAR BOXX2=450,BOXY2=190 You can draw the box with GBOX BOXX1,BOXY1,BOXX2,BOXY2 And say variables X and Y are the coordinates of your object, every time you change the objects position, afterwards run this code: IF X<=BOXX1 THEN X=BOXX1 IF X>=BOXX2 THEN X=BOXX2 IF Y<=BOXY1 THEN Y=BOXY1 IF Y>=BOXY2 THEN Y=BOXY2 Also DereK is much more clever of a name