Sabbatical Log: November 22nd and 23rd

This blog series is running about a week behind my actual work, giving me time to clean things up.  The date the actual work was done is in the title, horizontal lines indicate when I stopped writing and started coding.

The 22nd was the Thanksgiving in the US – I didn’t get much done.


Back at it on the 23rd, post-holiday. Probably still a light day, but I’m going to work on smoothing out room transitions in the cardinal directions. With any luck, I’ll get to the stair-style transitions.


I’ve got the cardinal directions working now.

If you watch the transitions, you’ll notice the interactions of collision detection and exit systems. An exit placing the player inside a tree (for example) will result in them getting pushed back into an exit zone. I like that the interaction here “makes sense” and is an emergent property of the two systems interacting, not an explicitly handled edge case.

That said, I don’t love the ExitSystem code. It explicitly calculates the desired end position of the player and camera, and takes over camera positioning during an exit transition. I’m going to spend some time making it less ugly before moving onto other sorts of exits.


I’ve now cleaned up the ExitSystem code, and written a few tests. I mostly added comments, collapsed primitive fields into structured types, and moved the camera-y bits over to the CameraSystem. The CameraSystem now has a notion of being “explicitly pointed” somewhere, rather than deferring to another system it still keeps track of the camera but allows other systems to make camera requests. I also moved most of the logic that fills out the FrameState during a transition into the ExitSystem, since it was mostly duplicated anyway.

The ExitSystem remains kind of big and complex, but it’s much more manageable now. I may need another refactoring pass after adding other sorts of transitions, but I’m fine with it for now.

Here’s an outline of the current code:

Next up are the other transitions, for now I’m going to confine myself to four: going through doors, going up stairs, going down stairs, and falling down holes. It makes the most sense to me to model these as colliding with particular objects, as opposed to the edge triggered-ness of the cardinal direction transitions.

Continue onto November 24th