I'm trying to set up a viewing clamp on the top, bottom, left, and right of my 2D world map. I want the user to be able to zoom in and out ( which is completed), and pan the camera (completed). But I don't want them to see outside a specific boundary. How would the math and programming look behind calculating if the user is seeing outside of the level boundary? Since the user can zoom in and out that starts to get a little complicated, and I'm not sure how to approach this.
Any help would be greatly appreciated.
The information I've gathered is the position of the camera for each side at the largest and smallest zoom. I imagine I need to have some sort of calculation that can figure the in-between numbers that are acceptable.
Side: Smallest /// Largest
Top (Y): 11.65808 /// 6.277246
Bottom (Y): -9.491721 /// -0.1629976
Left (X): 18.12113 /// 7.855795
Right (X): -18.29644 /// -6.274414
I also wonder if there's a more simple ray casting that can be used. Like making 4 boxes that surround the viewable area, and if the camera corners ray cast into any of them, the camera snaps back to where it should be depending on the box it ray cast on.
However, I'm not sure how the code would look for this raycasting.