How do i make an object stop if it reaches a certain point on a page?

I am making a game where you can move around in a certain area but the problem is that you can move freely outside the area i want the player to be in. Is there any way I can make it so that if the player reaches a certain coordinate on the page that he cant move any further?

Helpful info:
-I coded it so that everytime any of the arrow keys are pressed the player moves 16px to the direction chosen.

Thank you!

Source: jquery

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.