Snarl is a 3D maze game programmed using OpenGL and DirectX graphics. The maze is navigated in first-person, with the goal being to reach the end before the intelligent bot solves it. The game was partly designed to visually demonstrate the process a recursive search algorithm uses to locate an item (in this case, the end of the maze). The maze is constructed of cubes which create walls and paths for the player to travel. This maze is constructed from a 2D array of boolean variables. The starting and ending coordinates are also specified.
This program uses the SimpEngine modified from the book OpenGL Game Programming by Kevin Hawkins and Dave Astle. This engine uses a linked list to store every object in the game. When one object is told to draw itself, it will recursively draw all child members until the whole map has been drawn. Not only does this makes the creation and deletion of objects very easy, it means any object can be put in the list regardless of the scope of its creator.
The maze can be created one of two ways. An XML file can be loaded which specifies the attributes of the map. The program also has a built-in map creator which uses a recursive algorithm to generate a suitable path to the end based on the size of the grid specified. The map is constructed by placing cubes in a virtual grid. The places where cubes do not exist form the pathways, and the sides of the cubes themselves form the walls. A larger cube that is the size of the map creates the floor and ceiling.
The AI bot has its own class which steps through the maze recursively in order to solve it. The bot uses the right hand rule to perform a depth first search. A key combination can lock the camera position to the bot so that his movements can more easily be followed.
Custom eerie music creates intense playing experience.