Prevent player from walking outside the borders of the map

[finishes #47852481]