Devlog Meat #0 - SUBROOMS AND DOORSThe goal:
Quick dungeon creation, no hardcoding navigation, slap down tiles and done
How I did it:
In the room editor I have two tile layers - one for my subrooms (A), one for the dotted connections between them (B).
First my control object loops through all the tiles on layer A, using `tilemap_get_at_pixel` to find unconnected islands (these are our subrooms) and assigns a subroom number to each cell in an array grid:
(here we see parts of subrooms 4, 6 and 7, with empty cells being left at the default 0)
Then each door runs a loop that follows its dotted line tiles on layer B to find it's corresponding door (the position to send the player to), that door's direction (the direction the player will move into the other subroom, which also makes it easy to check the exit isn't blocked before entering), and the room number of the cell that door is in (so we can, for example, activate enemies in the new `current_room`).
If a door doesn't have a valid connection, on purpose or by mistake, it gets filled in with rubble:
The final step is these blue square camera zone objects:
If you squint a little, you'll see there are two of them, and three subrooms - the two smaller rooms share a camera.
At create they loop over the cells in their bounding boxes to see which subrooms they touch, and the control object has an array containing their (top left) x,y coordinates in structs, with the index matching the subroom numbers. Then when we go to a new subroom we simply animcurve the camera to the corresponding camera square's position. The fact they are rectangular introduces a design limitation that I'll fix later when I add more complexity to the camera system (and perhaps a custom editor), but it works nicely for now.
Finally, the system in action:
I might pretty this up by having the camera follow the tiles too, but I kind of like the snappiness