From Dungeons to the Overworld ๐บ
This post serves as an update to the previous post: Dungeon Excavation Using a Random Walk
The focus of the project shifted from the generation of dungeons to the generation of semi-natural looking land masses such as an overworld for a DnD campaign (or other TTRPG campaign).
I implemented an object oriented programming approach for how cells and a grid are represented and drawn to the screen. The information is encapsulated in a DrawableCell and DrawableGrid2 class and reside in the assets.py file. All of the changes to the code can be viewed here: Github: landmass-gen
What's New? ๐
Cell Shaders ๐
Cell "shaders" were implemented. Based on the number of steps taken on each cell in the grid, the RGB value for the cell is shaded by multiplying the red, green and blue component by:
(step_max - (cell_step - 1))/step_max
where step_max is stored in a field within the DrawableGrid2 class and determined during the random walk (see walker.py). So, if a cell has a step value of 1 and the highest step count recorded was 17, then cell_shader = (17 - (1 - 1))/17 = 17/17 = 1. The shader is then applied to the RGB of the cell by multiplying each color component by the shader. Therefore, cells with higher step counts will appear darker when rendered.
Biomes ๐ณ
I was not satisfied with how the cells were rendered in the previous implementation, that is, they were rendered with only one color. There was an additional color that was a product of the color_spill() method discussed in the previous post, but that color was always yellow or yellow-green. From a quick Google search, I implemented six biomes. They were represented by a dictionary in the biomes.py file in the form:
'biome_name': {
'landscape':(R,G,B),
'vegetation':(R,G,B),
'mountain':(R,G,B),
'water':(R,G,B),
'dist':(a,b,c,d),
}
A biome has RGB colors that represent what the general landscape will look like as well as the color for the vegetation, mountains and water. A cell can be rendered in a color representing the landscape, vegetation, mountain or water based on the dist entry for the biome, where a,b,c and d represent probabilities for that color (a + b + c + d = 1.0). Example, the desert biome has a distribution of:
- landscape = 0.9
- vegetation = 0.06
- mountain = 0.03
- water = 0.01
Comments
Post a Comment