In Wolfenstein 3D the world is a flat grid of squares ("maps are 64*64 max" in id Software's code) and every wall is the same height. For each column of the picture the game sends one ray across the grid until it hits a wall, and draws that column taller the closer the wall is: twice as far away, half as tall.
Measure the ray's full length and a flat wall in front of you bulges like a fishbowl, because the rays at the edges are slanted and travel farther. Wolfenstein's code measures the distance straight ahead instead: CalcHeight keeps only the part of the distance that points where you're looking, so every point on a wall facing you is the same distance away and the wall comes out straight. Walk right up to a wall and it holds that distance at a minimum: "don't let divide overflow".
John Carmack, in his note with the released source: "The ray casting refresh architecture is still reasonably appropriate for the game. A BSP based texture mapper could go faster, but ray casting was a lot simpler to do at the time." In 1993, Doom drew its walls with a BSP.
The maze, the textures, the field of view and the fishbowl in this film are our own simplified version, built in code.
Which game's hidden trick should we cut open next?
Sources: id Software, Wolfenstein 3D source code (WL_DEF.H, WL_DRAW.C, WL_MAIN.C, WL_DR_A.ASM) and John Carmack's RELEASE.TXT, github.com/id-Software/wolf3d.
Unofficial. Not affiliated with or endorsed by id Software, Bethesda or ZeniMax.
Sounds: Apple iMovie sound effects.
