Lately, I rewrote some parts of the lighting system of Fruit Wars (once again).
The old system had a “spreadLight” method that was called when a tile that emits light was placed on the map. This worked fine, but it did not work well with sunlights.
Why? Because an air block DOESN’T emit light. It receives light from above the map.
In the new system I redid this and split the calculation of light into two layers: “sunlight layer” and “tilelight layer”. To know the light value of a tile at (x, y) I implemented a method “getLight” that does something like light = max(sunlight[x, y], tilelight[x, y])
You can see the new light system in the following screenshot