Saturday, May 5, 2012

a maze

For Ludum Dare 23, I decided to have another try at a game I had attempted to make early last year, in which you navigate a maze wrapped around a cube that rotates as you cross each edge so that the side you would wrap around to flips up to face the viewer. At the time, I had tried a few different solutions to the flipping-around problem, none of which worked at all, and usually involved the cube catapulting the player off into infinity.

In Patience, I ran into a similarly perplexing issue with rotating this cube-of-cubes around in 3D space and still maintain some kind of intelligible structure so that the game knows which cube you're pointing at with you touch the screen. The problem is really that the cube is rotating around in 3D space, and so the real positions of the various points on the surface of the cube are just all over the place and require a bit of 3D math to normalize everything into a neat and usable structure. So I decided to just make it all static - the cubes don't actually rotate or move around at all. It's really the camera orbiting around the cubes that's controlled by the touch-drag input.

So for Ludum Dare 23, in the spirit of making some kind of "tiny world" (the community selected theme), I thought "well, if I were to take a maze and make a sort of planet out of it, that might work." And making things that are normally round in real life into boxes and cubes seems like a fashionable thing to do in games. So I went and revisited the maze-on-a-cube idea, with this camera-orbiting-around-the-cube idea worked in.

I should mention that I only decided to do the maze idea after going through a few other ideas which I was just getting way too ambitious with. A maze with dots, i.e. pac man without the ghosts, but in 3D, seemed like the right combination of coolness and simplicity.

Even with this simplified concept, the edge-flipping mechanic still gave me a lot of trouble. I spent the majority of the time I had for the jam just getting this right. As usual, the solution turned out to be much simpler than the various attempts that preceded it. There's a concept of "face local space", and if you go beyond certain boundaries within this space, you're off the face, and you're moved onto the adjacent face. The rest is really just keeping track of which faces are adjacent to each other, rotating the player's world-space movement around, and slerping the camera over.

The overwhelming feedback I got from this was that it is too short, which struck me at first as a little ironic for a theme of "tiny world", but ok, point taken. So I started working on a way to randomly generate mazes that wrap around this cube, because the alternative to building this out into a more complete game would be to make lots and lots of maze levels, make a level editor, and so on. Generating the mazes, in the end, requires less manual effort per unique maze generated - and, given that some kind of a mapping is needed to generate the maze data anyway, it doesn't require much of a stretch to simply be able to serialize that data into a file format. The only other thing aside from that to build an editor into the game would be to add a mechanic similar to the one in Patience where tapping interacts with the cube (i.e. toggling a wall space on/off) and dragging moves the view around.

The editor might come later. There's also the matter of simply getting the serialized data in and out of the game and onto some kind of permanent storage, which on mobile devices is not quite as straightforward as it is on PC. There's usually some kind of cloud sync-y type stuff involved, which would be completely new territory for me as a developer at this point. Which would be cool, no doubt, and I'm sure that's something that we'll be seeing in neocade games at some point if not soon - so.. who knows. I haven't really thought about that much just yet. When I do it, I'd like to do it right.

Anyway. For the sake of making this a complete game experience that's worth a buck forty two, I'm working on a system for randomly generating the maze each time the game is played. This way, you're always getting a fresh thing to navigate around, and we don't have to go through all the pomp and circumstance of writing hundreds of levels. Just generate the mazes and be done with it. Pretty simple. Still thinking through whether it should still be 'collect all the noms to win' or just 'find your way to the exit'. Collecting stuff needs a somewhat more open labyrinth, rather than a maze with a definitive start and end point, which is what the maze generation algorithms I've looked at generally do. Modifying one of them to make a more open structure seems easy enough though (fingers crossed)

As I said before, the capabilities do exist for this to grow into something a little more user-editable, so if there's enough of a demand for such I thing, I will most definitely see what I can do.

No comments:

Post a Comment