Maze
Maze
Random maze generation game
This is a learning application that I use when trying new technologies. The algorithm for the maze generation is simple. The start point is located at (2, 2), then it picks a direction and moves two places, and removes a “wall” then it will remove the wall connecting it’s current location and the it’s previous location. Then it starts over and picks a new direction, if it finds it’s self locked in a corner each step it’s taken is stored in a stack and it will pop off to it’s previous location and check for a direction, once it finds no new direction and the final location (start location) is popped off it’s considered complete. Then the system will figure out a finish location, it’s located in the lower right corner of the maze and places a “finish” mark. Once the player (indicated by the “@”) reaches the “F” in the lower right it’s game over, a message will be displayed and it exits to the command prompt. The solver (indicated by “+”) functions much the same way, it starts at the stating location and follows the path, always turning right and down first, it reaches a dead-end it also removes it’s previous location from a stack and check it’s directions, repeating this process until it finds the “F” in the lower right corner. The purpose of this program was for an introductory course I took on C, the requirement was to write a stack in C and I wanted to make some a little more interesting and try and push for some just a little more fun. I spoke with the instructor and he was happy to allow for my changes. The C version was only the start, having known and program in C++ for many years at this point I choose to refactor it to C++ I kept the ncurses interface as I was wanting to keep the original C behavior just make objects that I could later use with a different UI. My next version to migrate the code to was Objective-C, it utilized OpenGL for draws and created a 2D version. I learned a lot about Objective-C and writing for Mac OS X (10.4 – 10.8) at the time, in this process. Some of the hardest parts were dealing with Obj-C’s dynamic typing and understand Cocoa to access OpenGL Views in Mac OS X. One of my goals was to make a 3D version and I ended making a new view for the 2D version make it 3D, I wrote a simple engine that would only render the room and the next room that the user was currently in. I try doing a ray-cast from the player’s direction but ended up with some instances where the next room wouldn’t be rendered and it was visible to player. I know it was a resolution issue with my rays but it was just easier to rebuild the data structure to group contiguous empty spaces as single room and that each end was a portal to another room, and I would just draw the next room. It was quicker to do it this way as I didn’t have to try and hope my ray resolution was high enough for a ray to pass through a small sliver of the next room that might be visible around the corner.
When I started learning C#, I started writing it for C# and XNA. How ever with the end of support for XNA I wrote it in C# using SharpGL to access OpenGL. In the process of learning Windows Store App development I needed to drop SharpGL and I switch to SharpDX to access DirectX. I’ve also written a 2D version in C# utilizing Win2D. I’ve also gone back to the C version and worked on porting it to homebrew libraries such as those used on the PSP.
This project has been a nice tool to learn a new language or new technology.