[Prev] [Home] [Next]

B. Flying and crouching.
Recall that the player's height is set to be 32 units. This means that the player's eyes (imagine the player's eyes are exactly on top of the player's head) are looking straight at the walls at point 32. Since 32 is one half of the walls' height, having the player's height at 32 makes the player's eyes halfway between the floor and the ceiling (see next figure).

What if we change this value? Surprisingly (or maybe not), the walls will shift either upward or downward depending on whether the player's height is increased or decreased.

Thus, to make the player as if he/she is flying (or leaping), we can simply increase the player's height. Similarly, to make the player as if she/he is crouching, we can decrease the player's height. The height should not be allowed to be less than 0 or greater than walls' height, because doing that will make the player go over the ceiling or sink into the floor.

The next figure shows why this method works.







One counter intuitive aspect of this method is this:
the vertical center of the projection plane must always be perpendicular with the player's eyes. (I.e.: the projection plane must always be parallel with walls - they cannot be skewed toward each other.) The best way to conceptualize this is to imagine a person "aiming" through a camera lens. The person always aims in forward direction at 90 degrees angle; even when he/she is crouching or standing on top of a box. I.e., we cannot skew the projection plane like in the next figure. The reason for this is this: if we rotate the projection plane along, the walls will be slanted (no longer parallel with the projection plane); and the rendering process must then take this into account. That means, more complex calculation will be required, and the rendering process will become terribly slow.



This is how a more realistic looking down is supposed to happen,
but we don't do this. We use tricks like in the previous figure, instead.