HW4

OpenGL Maze

This is a program which implements a 3D maze in OpenGL. There are several different types of objects in this maze. There are walls which users cannot pass through and don't change. There are doors which can be unlocked with corresponding keys (but no other way). Keys can be held by the user, but only the most recently picked up key will be displayed. The end of the maze is the same material as the ground (since I couldn't find a way to map more than 2 textures in OpenGL) and the user exits the maze and the program by running through the goal.

Users cannot clip through walls, even on corners. I spent a lot of time trying to avoid clipping, and having held items not clip through walls. The main bottlenecks I encountered were either related to how I stored the level information. Originally I tried to use a 2D array, but ran into seg faults sometimes, but not consistently. So I switched to something a bit more convoluted: a map whose key is an int which holds a vector of pairs. Each row in the level is a key value in the map. The vector of pairs keeps track of the column in the level and the character that is in the row. This works because the levels are rectilinear. A main problem here was realizing that I was storing things like a 2D array, but trying to access them as (x,y) coordinates when really it was indexed like an array.

Here's an interesting picture while I was trying to figure out clipping with objects


Video Demo

Video demo can be found HERE (Google Drive link). It shows two clips of two different scenes. These scenes can be viewed in the drive folder HERE that also contains the demo and executable.

The first scene is basically a long hallway that shows all five key/door pairs with five different flat colors. The user can pick up any of the keys, but the most recent one will be displayed on the screen as if they were carrying it. For this implementation, it keeps track of keys the player has gotten before so a key could be used if isn't the one being displayed.

Executable HERE (Google Drive link) compiled on Mac. Code below.