Thursday, February 16, 2012

MazeGen v0.0.1

Hi guys, bit of an update for you all, and the introduction of a new piece of software to my online portfolio! I present to you all MazeGen. For a few moths now I've been infactuated with Maze Generation tools and how to create dynamic mazes that are both solveable and highly complex. I spent a lot of time on Emanuele Feranato's site (found here) which goes through how maze generation works and there are a few open source code snippets on the matter also.

The main reason that I was interested in maze generation is that I have a passion for maze type games - anything that is both puzzling and interactive. So mazes and maze generation is perfect for me! What I originally set out to do was to use the code on Emanuele's site to in turn create physics objects from the generated maze, which could then be manipulated as I saw fit.

The way in which I envisioned the code working was this:

 - given a height and a width the maze would generate
 - the maze would then be sent to an xml file, with each row of the maze having a row in the xml file, 1's representing a wall and 0's a gap. This would allow for the maze to be broken down into something akin to:



- The XML file would then be parsed by a physics creating loop which essentially looked through each row, and for each 1 it found, create a physical object. Thus leaving us with a maze!

I had several fairly major problems along with way. My main issue was that I was targetting Corona SDK for the project - which, took on the actual code generation part of the task admirably, but when it came to converting the XML file in to a tangible maze I found that it had some pretty major shortcomings. The biggest of which is that you can't actually create a compound physics object, which is a large object made up of smaller objects all tied onto the one entity, the reason that I needed this was that in order for the object to remain a whole maze would be that each wall was connected to the ones next to it, without this, say for example when the maze rotated, each individual block rotated about it's own axis as opposed to rotating about the center of the maze.

After a few weeks of frustrated bashing away at the keyboard I turned back to my flagship language Flash to get things moving. I re-wrote the maze generation code and put Nape in as my engine of choice, which turned out to be a godsend, as Nape allows you to push as many "shapes" as you want into a single body before creating that body in the world, which in a nutshell was exactly what I needed.

So, now that I had a working system, I went about modifying the maze generation engine to make things easier say for a person wanting to make a maze based game. The major things that I wanted to produce with this piece of software was ease of use and simple interface interaction, this alpha release accommodates these features, as you can see from the screen-shot, there is some very limited functionality. The user manual (however brief,) will uploaded and available for reading along with the swf.

Here is a link to MazeGen v0.0.1 - this will open up in a new pop up window.

I'll give you all a quick rundown of how it works - enter in a width and a height into the respective boxes, and then hit generate. You'll get a image of what the maze would look like, if you don't like it you can just hit generate again until you find a maze that you like.

When you do, click the Save Maze to XML File button, this will push the Maze into the XML file, that particular maze is now "saved." And you can enter in a new width and height to get a new maze to save.

Once you have finished generating all the mazes that you want, click the Save to disk button, this will give you the save file prompt and you can select where on your computer that you want to save the XML file.

v0.0.1 is by no means bug free - I expect that there will be problems, but the major ones I hope to have plugged by now.

In future versions I'm hoping to introduce a number of other things:

 - Multiple export types
 - Load XML file
 - Edit Mazes that are in the XML "stack"

Thanks for reading through all of this, and I hope that you have read up to here. Please feel free to have a play with it and I'll soon be uploading a video of how to get the XML file back into Flash and generate some physics objects from it!



Post a Comment