In this game engine i am working on, i have a camera problem that i will explain in a moment.
Before i continue thought, i must state that i aleredy have a few idea on how to resolve it, but i feel all of them are "awkward". So i come here to hear about yours opinions.
The problem is kind of hard to explain, i will try my best to be as precise as possible.
I have a 2D sidescroller game. In this game is a Camera Class that can move around dynamically, that means it will try it best to keep up with whatever it's bound to.
The camera follow a simple rules: Don't go out of the Level. This mean in a 100x100 Map, the camera won't go left of tile 0 or right of tile 100.
With this come 2 major problem
1. If i wants to make a "secret" area where i do not wants the camera to enter before the player do.
2. If i wants to stop the camera right at the floor level, even if the level go below the floor eventually.
if i am not clear enought, i have attached an image to show the problem.
In picture one, you can see the level Editor. I made a corridor leading to a pit. Picture 2 is zoomed it with the player spawned. You can see in picture 2 the problem. I wants the camera to stop at the floor and not go under the floor until the actor is nearby the pit.
So i got somes idea on how to solve it, but like i said earlier, neither are spectacular.
1. Flag somes tiles as "Don't go in here yet". If the camera is about to show them, stop the movement.
2. In the map header, tell the camera where it can go and where it can't go.
3. Disallow the camera to enter "empty space" or tile flagged as "secret space" (a trigger would unflag such area as soon as the player touch it).
4. Put trigger everywhere in the level to tell how the camera should behave.
Personnaly i would go with option 3 but i wants to hear what everyone is thinking. Maybe there is a better solution i am not thinking of.
Ps: Graphics are just placeholder.