random spawn of monsters on the map
Recently, I changed the way monster generation works on the map. In the previous version, I manually configured a layer containing X,Y vectors to define the points where monsters could spawn. However, I quickly realized that this approach was not ideal, since I would need to manually configure every map in the game with possible spawn positions.
This ended up not making much sense, because the map itself already has a configuration indicating whether it is a safe zone or not. In other words, if the map is not safe, then it should automatically allow monsters to spawn.
To solve this, I replaced the fixed vector-based configuration with an algorithm that automatically analyzes all collision vectors on the map, such as trees, rocks, and map boundaries, and identifies the free points within the playable area. This allows me to obtain all valid positions for safely generating monsters without the need to manually configure each map individually.
In the video below, the algorithm is already working. The current map configuration is set to populate 2% of the available area with monsters, and this was the result.