Maze

This project will describe how to make a simple first-person 3D maze game. We will build up the code step by step and explain at each point what that code is doing. This "project" is more like a textbook than it is like a class assignment; the idea is to walk you through one way of doing something so that you can then modify this approach for other games of your own.

The first step is to simply create a maze game in which I am looking down on the maze from the top and can move the player around with the arrow keys. Although the appearance of this game is much different from our final project, we will find that a lot of the code is the same, because the form of the world it is drawing is the same as the form of our final maze game.
Maze: Third Person

The next step is to try to make our maze game more "first person." In the version we have so far, the board stays in place, and the player moves around it in steps, jumping from one "cell" of the maze to the next. We would like the player to be able to move around smoothly, and to make it move "first person" we could have the player always appear at the center of the screen, and have the maze move around the player instead of the player moving around the screen.
Maze: First Person

With some simple application of similar triangles, it is easy to convert our existing version of the maze program, viewed from the top, into one viewed from the perspective of the player. That version still has walls represented as simple lines, but they are now lines on the ground, which are rendered in 3D. What is more tricky is trying to extend these lines out into solid walls; tricky, because if walls are solid, they need to be able to hide whatever is behind them. To do this, we will adopt a new way of drawing the maze, starting from where the player is and treating each open wall as a "window" through which only part of the rest of the maze can be seen.
Maze: 3D

If you're used to playing modern first person shooters, you probably still aren't much impressed by our maze game so far. After all, it is all black and white, with lines showing the walls; you're used to games where the walls have textures, images that are painted on them. In this section, we will look at how to draw textures on the walls and floor, and how to draw a "sky" texture that behaves as if it is painted on a far distant wall.
Maze: Textures