Comp 3501 - Labyrinthian
Comp 3501 - Labyrinthian
Table of Contents
1. 2. 3. Introduction ............................................................................................................................. 3 Game Rules and Player Interaction......................................................................................... 3 Project ..................................................................................................................................... 3 3.1 Special Features................................................................................................................ 3 What special features were incorporated into the Project ......................................... 3 Special Feature .......................................................................................................... 6 3.1.1 3.1.2 3.2 3.3 3.4 3.5 3.6 3.7 3.8 4. 5. 4.1
Game Originality .............................................................................................................. 7 What was not accomplished ............................................................................................. 7 What was hard .................................................................................................................. 7 Data Structures, algorithms and Performance .................................................................. 7 Collisions.......................................................................................................................... 8 Physics and AI.................................................................................................................. 8 Future Work ..................................................................................................................... 8 Present the project/game software design ........................................................................ 9
1. Introduction
Labyrinthian is a game where the player must navigate their way through a dimly lit maze to reach the exit. The maze contains deadly traps that the player must overcome to escape with their life. Among the traps are a few rare items that will aid the player, helping them reach freedom in one piece. The game has a first person shooter play style with a horror/puzzle solving genre. From the players perspective the main objective of the game is to reach the end of the maze as fast as possible.
3. Project
3.1 Special Features
3.1.1 What special features were incorporated into the Project
A number of special features have been incorporated into Labyrinthian. The features that are most prominent include maze generation, physics, lighting, sound, interactive menus, game score saving and animation of game objects. The effects of maze generation are visible the moment the actual game begins - this covers the shape of the maze to placement of traps inside. As can be seen in Figure 1, a level is made up of multiple single dimension grids which use square blocks in order to create sprawling paths. Though physics are not directly visible, it is observed when the player moves throughout the maze. All objects except directional arrows use physics in order to provide fluid interaction that simulates a person moving through a three dimensional space. Collisions between the player and terrain results in restricted movement and any rolling ball that collides with the player will push them around. In Figure 1, the effects of directional lighting are clearly seen. There is only one light in this level at the moment, which consists of a single directional light that points outward from the players perspective. The use of lighting in the game creates a dark atmosphere that adds suspense to the game play. Sound has been implemented in the game in order to provide audio queues to the player. At this point sound effects have only been added for menu traversal and a background track during the actual game. Interactive menus have been added in order to let the player choose what they would like to do during their time playing the game, whether this be exiting or choosing a different level. The level selection level is shown in Figure 2. Score keeping has been implemented in the game, and is visible in the bottom corner of the interface in Figure 1. The final feature implemented is rolling balls, as shown in Figure 3. A rolling ball is simply a sphere that follows a designated cycle in the maze. Rotation is calculated in order to give the player the feeling that it truly is moving in an ordinary fashion. Features our group is most proud of include maze generation, menus and the rolling balls.
Figure 1 - Gameplay
Figure 2 Menus
3.1.2
Special Feature
The special feature most integral to the success of our game is maze generation. Through the use of basic algorithms, random procedural generation of mazes ensures that each level will be different upon every encounter. There are three main phases in creating a level. The first phase of generation is, depending on the level size, to create the structure of the mazes that make up the level through placement of walls. A randomized minimum spanning tree algorithm is run upon a two dimensional grid of walls, this ensures the connectedness of the maze. Though many algorithms could be used for this, including shortest path, depth first search, and breadth first search, it was decided to use a modified Prims algorithm as it gives mazes a structure that includes less lengthy hallways and more choice on the players part. The second phase in level creation is to find the connection points between the different mazes within each level. On the bottom maze of each level, the start is chosen randomly. After the start is chosen, Dijkstras algorithm is used in order to find the longest path from this position and is used to be the connection point to the maze above. The process of connecting the end point of each maze with the start of the next and then finding the longest path to its own end is repeated for each successive addition to the level. The third phase in level creation is to add rolling balls to each maze of the level. By traversing each maze and keeping track of the largest difference in height of the tree where a backpath exists, we can find the longest cycle in the maze. Once the longest cycle is found, we can simply get a rolling ball to follow this path for its entire life. The challenge in implementing this algorithm is making it so that the mazes are both challenging and random at the same time, whilst also providing fluid gameplay. Since our level is created 6
using a minimum spanning tree algorithm, the difficulty lies in modifying it in order to not include every space into to traversable space. Several rules had to be added to the algorithm in order to not create walking space when adjacent neighbours have already been added; the way this problem was solved also allows for loops to be created, which lets obstacles move fluidly through the maze without having to backtrack too often.
A special data structure, SpaceNode, was added to the game in order to perform algorithms on Space objects without modifying the underlying structure. This class holds variables such as the distance from source, pre and post counters, parent and children.
3.6 Collisions
The collisions are handled by the physics engine that we implemented. We assign collision groups to different objects in our game that define which objects can interact with each other. The physics engine automatically detects collisions depending on collision groups and passes the incidental objects into a callback handler in our main game class myGame. After we have decided that the collision is valid, and the objects colliding merit a response, we directly apply the correct action. The performance of the game declined dramatically when using large boxes, as collisions checks had to be performed many times by the engine. To get around the issue of large boxes, we split them up into many smaller boxes and the performance was returned to normal.
4. Software Design
4.1 Present the project/game software design
The main classes that are unique to this game are the Level, Maze, Space, Wall, Trap, GameMenu, Player and GameObject. The building block of this game is the MeshObject class, where each visual element of the game will be made up of objects that have properties that will obey the laws of physics in some way. MeshObject will hold variables such as the objects position, velocity and rotation in space. This position is sometimes held within a physics object instance called NxActor. The Wall class is specific instance of MeshObject that will provide the behavior of being a solid obstacle in the path of the Player, and will contain information about the geometry and texture of a Wall object. The RollingBall class is a specific instance of MeshSphere that will provide a balls behaviour in the game. The Player class is a specific instance of MeshSphere that will provide dynamic behaviour depending on player input to guide it through the world. The player will not be drawn since it will be first person but this class will contain the specific behaviour a Player object will follow when reacting to input. This class will also contain information about the amount of life that the Player has remaining.
The Space class is used in order to maintain the structure of a particular Maze as well as keeping track of objects within it. In order to run Algorithms for maze generation and game object placement, Space is used in order to simplify the world by splitting it into even quadrants defined by a Space object. This class specifically keeps track of whether there is a wall, floor, or a trap in its location. The Maze class contains the structure of a single horizontal section of a Level, which is split up into Space objects. This class maintains an array of Space objects in order to run algorithms for automatic generation of Maze structure. The Walls and Traps are also stored in order to provide easy access for drawing the Maze. The Level class contains information about the difficulty and time data of the current level as well as the structure of the multiple Mazes that are combined in order to create a full Level. This class is used in order to determine both how many Mazes there will be and how difficult they will be. The Menu class is used in order to display a selection of elements and relay input from a user regarding the choice they have made. This is used in order to select the type of game, select settings, change the current level difficulty and for post-game decision making. The PhysicsEngine class is an instance of NVIDIAs PhysX engine that contains instructions for simplified creation of physics objects. This class maintains a physics scene and its objects. The AudioPlayer class contains all the code necessary for audio.
5. Technologies Used
This project was entirely programmed in C++. The 3D graphics for the game was handled by the DirectX9 library. In order to calculate collisions and movement, NVIDIAs PhysX engine was used. The game uses the irrKlang audio engine in order to broadcast sound effects.
10