3D Maze

New dimension adds a whole new dimension to maze exploration.

Download: Maze3D.zip – 582kb

This program uses my Ascii maze generator for data to make a maze, then allows you to explore it in a 3D OpenGL context.

Maze screenshot

Screenshot of the entrance to a generated maze. Click for full size.

When you first run the program it will launch a console window and ask for a width, height, and a random seed number. 10 – 50 is a good range for the width and height, but you can make it larger or smaller than this if you want.  On a 3ghz core a 50×50 maze takes just a few seconds to generate but a 100×100 maze takes around a minute and is very large, runs choppy, and causes problems with collisions on slower gpus.

Controls: W A S D movement with strafing, arrow keys for movement with turning.  Mouse for  looking around. Space bar jumps. More keys listed in game, press F1 for help. Hold F2 to gain control of your mouse (unbind from game window).  Esc closes the window. Feel free to maximize the window, probably won’t slow it down (depends on your system).
A Few Tips: A green gem is generated at the entrance and a blue gem is generated at the exit. By jumping you can get a glimpse of what is on the other side of the wall in front of you, as well as the location of the gems.
Known Issues: If the cursor is visible or not responding, click the window and press F2. Two things may cause unresponsiveness on the keyboard, if you have caps lock enabled none of the alpha keys will respond, also if the window is not selected only the mouse will respond, try clicking the window, or ALT-TAB to select the proper window. On larger mazes if you are dropping to low frame rates you may occasionally walk into, or through walls. Right now the only solution to this is to generate a smaller maze or get a motherboard with a higher bus speed to your graphics card the bottleneck may vary from system to system.

Click for full size.

Geek stuff:
I learned most of the OpenGL at Swiftless I found his site to be the most straightforward and easiest to conceptualize. The generation program is pretty accepting of information, try putting in 0 x 0 maze. Or 800 x 1. If you are curious how the maze is generated, there is more information on the post I made when making the generation algorithms.  You can have some fun playing around with different .bmp’s in the texture folder. Just make sure they are 24bit and must have the exact same name.  You can use paint to easily convert an image to the proper format.  The current textures I got here.

There is an issue with large mazes currently, my laptop runs a 100×100 maze at 15fps compared to a 0x0 at 1000fps you shouldn’t really  have any problems at around 100 fps. I think the actual issue is with sending so many vertices. It would probably be fixed with a vertex buffer, but this would only fix the problem for computers with full graphics cards, I programmed all this on a laptop so even with a vertex buffer all the info would still reside on the same stick of RAM.  And a desktop computer would likely have a much higher bus speed to the graphics card anyway(I guess). So the other idea I had would be to divide up the maze into small chunks, maybe 5×5 or 10×10 then display only what is needed per frame, considering frustum and location. I think this would probably be a couple days worth of work and I really need to get in the habit of focusing on priorities. Everything I add will only open up more avenues to add more, and this project really doesn’t have a future, so I think it’s in a fun, playable state and will probably forever remain thus.  I thought about adding logic to detect when the player reaches the finish, but I decided I like it better when you decide how you want to play, and not distract the player with my rules. I also like not having a minimap or any gui user interface or a splash screen it’s just the game engine. Onward to bigger and better projects!

Todo: (don’t hold your breath)
-Chunk maze (see above)
-Add stencil shadows
-Add normal maps
-Add rotational momentum


Download: Ascii maze generator – 164kb

Screenshot of program output. Click for full size.

Cool, but what’s it do?:
This maze generator will make (for all practical purposes) an infinite number of mazes  you simply choose a width and height (restricted only by the console), and choose a random seed.  A random seed will allow you to create the same maze multiple times, just make sure you enter the same width and height as well.  For example, every time you enter 38 wide 10 high 19 random seed, it will always give you the same maze.  But changing any one of these variables will practically always give you a completely different maze.  Have fun and let me know what you think!

Geek Stuff:
The maze construction works by first setting up a template I put together after studying this then randomly placing blocks onto the maze one by one and ensuring all the maze is accessible, if a piece is placed that would divide any of the maze into a separate section, that piece is removed and a new place is found.  There is a threshold for number of fails and it increases the larger the map gets.  So larger maps do take significantly longer to make than smaller maps.  Additionally, this is not multi-threaded, your single core cpu’s are not at a disadvantage!  That being said, it really doesn’t take very long to crunch a new map.  I would like to eventually export the data to an opengl environment but until then, bask in ASCII’s glory!

(10/08/11) I have updated the program and moved to a different IDE (and compiler) for better compatibility.   The application is now much larger but no worries about an installer or having all the required dlls (yay).  The old build is still available, but you will need Visual Studio C++ installed to run it.  The program is now more efficient at creating larger mazes.  There are actually two fairly similar maze generation algorithms, one is more efficient early on and the other is more efficient as the maze begins to fill up with blocks.  So it starts off with the one, scattering blocks randomly, many times on the same tile as last time and then once I start reaching diminishing returns with the first algorithm a smarter algorithm finishes up, never trying the same block twice.  The difference is really negligible except on huge maps you have to scroll to see (eg. 38×140) but I’m a dork.