The program below implements a (currently naive and inefficient) line-of-sight algorithm for a grid-based 2D game in JavaScript. To see the source code, visit

Use the W, A, S, and D keys to move around. The blue square represents the player's current position. Brown squares represent walls, which block both vision and movement, while gray squares represent fog, which blocks only vision. Green squares block neither movement nor vision. Black squares are not visible from the player's current position, either because they are obscured by obstacles or outside the maximum viewing range.