A first-person engine in 265 lines

A first-person engine in 265 lines

If the ray hits a wall, it measures the distance to that wall and draws a rectangle in its column. Our goal is to end up with an array that lists each wall the ray passes through as it moves away from the player. We check x and y independently so the player can slide along a wall:

The walls would be pretty boring without a texture.

Source: www.playfuljs.com