This project began as two separate side projects. One being a destructible 2D world using the Marching Squares algorithm. The other being an algorithm to generate 2D shadows for point light sources.
The World
The world is infinite and procedural. Tiles are generated around the player as they explore in any direction. The world data comes from a series of Perlin Noise layers which define different features such as terrain elevation as well as underground features such as cave rooms and cave passageways.
World data is only saved after it’s been modified. Once the player destroys part of the world, the affected tiles are added to memory in case the modified tiles are revisited after having been unloaded. This allows the world to not consume significant memory during normal exploration.
Lighting Engine
Light is rendered as procedural mesh geometry overlaid over each rendered frame. The lighting engine is responsible for updating light geometry whenever the terrain is altered by the player or loaded during exploration.