on 18 Oct 2012
Tonight, I wanted to slip an easy feature into Vox Venio. “It’ll only take an hour or so”, thought I, “then I can play a game rather than code one.” It was not to be so. There was an error, and like a racist cop I had made my mind up that a certain Lambda expression was to blame because, well, they’re naturally shifty buggers. Hours of investigation later it turned out it was some innocent-looking piece of code that just needed a minor tweak.
Stupid mistakes. Part and parcel of programming. But don’t worry, the Lambda expression was set free with only a moderate amount of refactoring.
What was I doing? Well… from previous posts you may recall how characters in an XML file map to tiles in the game. That’s all well and good when one has featureless programmer art, but when the real art starts coming one can start to realise there’s a problem.
Take a look at the first image from above. You can see how these crates are not featureless gray blobs — quite the opposite. They have distinct edges. The top looks different to the bottom, the left from the right. There’s six unique tiles in all. That would, up until recently, have required:
But with my latest code it’s possible to give the level tiling code some instructions on how to treat the same map character differently based on its neighbours. For example, you can instruct tiles that are on the right-hand edge to use the appropriate right-hand-side textures.
You can see the XML for said instructions in the second image. It means that the map can go back to looking like this:
Of course it’s not perfect. And I’m not just talking about my predisposition for stupid mistakes. There’s something more inevitable. For something like these shipping-crate-structures there are going to be problems such as what’s shown in the third image.
There are at least two fairly simple workarounds to this, workarounds that aren’t as dire as going back to the old way. I am too lazy to explain, especially exceeding time budgeting as I have, so I’ll leave it as an exercise for the motivated reader.