08 - Fog of war
cast(originX, originY, directionX, directionY, maxDistance, options)
Finds where each ray of the fan stops.
each(originX, originY, directionX, directionY, maxDistance, callback, options)
Walks that same ray again, only as far as it got, and reports every cell it crossed.
It is the only query that reports empty cells, which is what a fog needs: every other one answers with obstacles, so a fog built on them would reveal the walls and leave the floor between them dark.
This is also the only example that remembers. The others recompute everything on every frame; a fog is a set that only grows, which is why a cell can be in three states rather than two.
- Never seen: covered by the dark layer.
- Seen once and remembered: covered by the faded layer.
- In sight right now: not covered at all.