Saturday, September 7, 2013

Refactoring can be painful


Since we last met, I added in some (placeholder?) icons for various things in this game - a key, a gate, and the exit. Also, I'm reusing a player character icon from my last hex game, The Lair of the Rat King. The icons are just dropped anywhere on the white tiles, so there's no guarantee that the player can reach the key in order to open the gate and then get to the exit. In fact, in the screenshot above, the player can get to the exit without mucking about with keys or gates.

I've got a plan for positioning the exit, then positioning the player, then positioning the gate to be between them, then positioning the key to be between the player and the gate. "Between" is a path-finding thing, in this case. Should be easy.

One thing you can't see here is that there's a "camera" that pans around the level to focus on the player character once all the tiles have been placed. This was working acceptably well, and so I started pulling the camera into its own class, and in so doing, got things mostly broken for most of the past 12 hours.

But things are back to functional again, and it's kind of fun just watching the mazes be generated.

I'm beginning to wonder if there's a bug in my maze generation code - I've seen some mazes that have surprisingly long, straight passages. I've seen more than once a level that's just a single straight corridor, with no turns. That seems really unlikely to happen once, much less twice.

No comments:

Post a Comment