I've been looking at similar questions posted on Stack Overflow (and elsewhere) but they seem to either only deal with rectangles, which I can handle well at this point, or are more complex than I can currently wrap my head around.
I'm moving a sprite around the screen via mousedown
events and want to lock it from moving "out of bounds". The bounds could be something simple like this room:
Where the green is movable space and the red is restricted. Am I better off breaking this down into something like 1 long rectangle and 2 triangles (or groups of squares to represent a triangle with jagged edges) or is there a basic concept that I should look towards to specify the coordinates of the "walkable area" and verify that the user is always "within bounds"?
I'm coding this in JavaScript and am relying heavily on jQuery.
Edit: Considering I'd potentially need to have limitless points (if the room had more than 4 points) would I be better off using something like A* to generate the paths?