When exploration is the driving goal of your game, you want to make it easy to navigate around the game world and contextualize your current location. Breaking the world into discrete rooms is important to this end, since it helps the player break the problem of navigation down into manageable chunks and contains any puzzles and encounters in a known area. Today I implemented rooms in my map engine:
I’m not quite satisfied with the transition between rooms, but it’s good enough for the time being. As you can see from the video, the game loads and unloads the dynamic content (like enemies) and physics model of each room as needed. This will make it a lot easier for the physics engine to cope with lots of on-screen action as the world grows in size, since only the current room is simulated at any time.
I have a couple things to note about this implementation before I sign off.
First, rooms are rectangles. At first blush, this would seem to impose a constraint on level design: that any two room exits to the west, for example, would need to be vertically aligned. That’s not actually the case, owing to how it’s implemented. There are two ways to exit a room: either enter a door or leave the room’s boundary. Doors will be smart enough to guide a player into any adjacent (or overlapping) room in their direction, even if they don’t sit on the room boundary, and I can add “virtual doors” to hidden passages if I absolutely need to. I’ll post a screenshot or two if and when this comes up to demonstrate what I’m talking about.
Second, before this change, the position of a tile was located at its center. This makes some things convenient, but when it comes to working with Tiled maps, where you can draw object layers on top of tile layers, you really want this position to be the top-left corner of a tile, so that what you see in the editor will match up with the world you build in the physics engine. I took the time to make that change, since it was leading to some less-than-obvious behavior in the implementation.
At this point I have the basic mechanics of level creation, destruction, and movement working about how I want, so I’ll be moving on to prototyping various weapons and power ups to figure out which ones will feature in the game. Actually, I lied: before I do that I need to get shootable doors working and add selective destructiveness to the mapping system. But those are both small, manageable changes I hope to bang out tomorrow.