Fog of war #66
Main sprite. Added fog of war mask.
2. Render it with "destination-out" on the "fog-of-war" layer. "destination-out" on canvas reveals the background which is the "grass" terrain.
3. Applying random or sequential rotation (0, 90, 180, 270 degrees) to the mask helps shaping the fog of war.
This is how it looks in-game.
4. If it helps I can also add a shadowBlur effect.
Or shadowBlur + mask rotated (with 45 degrees angles as well).
If you care about logic as well, in my situation I can choose a shape (circle, square, diamond) and compute that on a [0,1] matrix grid and know exactly what cells were uncovered. Once a cell that contains an Entity object is uncovered, you can include it into the rendering queue.
Example of a diamond shape applied to a flat [0,1] grid
Let me know of ways to render and update a fog of war.
Clearly mine represents a particular case, but I'm interested in all kinds of implementations that are out there.