How do i make game boundaries?

is it just me or is this WAY harder.
I think I’ll stick to this:

if (this.hitTest(player){
player.axis -/+ speed
}

player = player
axis = x/y
-/+ = -/+
speed = the player’s speed