World generation is a little project in python who the objectif is to generate a world with a simple preset. The generation is volontary "simple" and is the fruit of simples maths rules.
The first step is to implement a preset file, a preset file is a .json
. The structure is :
//Preset.json
{
"biomeCode" :
{
"name" : "biomeName",
"code" : "biomeCode",
"color": "biomeColor",
"weight" : "biomeWeight" // The weight define the influence of your biome
}
}
A complete exemple : here
Now, you can create a world with preset file :
from source.tools.load_biomes import load_biomes
from source.classes.world import World
biomes = load_biomes('assets/output.json')
w = World('name', 100, biomes, False)
To generate a world you need to set biomes center :
w.set_biomes_center(5) #Number of biome center
And, you can fill it :
w.fill_world()
If you want to have a visual representation of your world, you can use the
show function : source.utils.show
. It loads a world and generate a graphic version into the folder assets/output.png
.
from source.utils.show import show
show(w)