The program generates a heightmap in PNG format based on Perlin noise.
The map is divided into 5 types of cells (1 cell = 1 pixel = 1 square meter):
| Cell | Default Color | Height (Y coordinate) |
|---|---|---|
| Water | Blue | -1 |
| Plain | Black | 0 |
| Hill | White | 1 |
| Mountain | Gray | 2 |
| Cliff | Dark gray | 3 |
Generation is configured via config.ron in the root directory:
| Field | Meaning |
|---|---|
size |
The size of the world (map). |
size_k |
The smaller the value, the fewer the mountains and lakes, but the bigger their size, and vice versa. |
borders |
If Some(tile), the map is divided into tilextile cell chunks with borders in the form of mountains. |
seed |
Generation seed. If Some(value), the map will always be generated identically for the same seed. If None, the seed is based on the current time, producing a unique map each run. |
*_color |
RGBA colors for each cell type. |
If config.ron is missing or invalid, default values are used automatically.
The generation seed is derived from the current time, so every run produces a unique map.
Example config.ron:
(
size: 1280,
size_k: 0.1,
borders: Some(64),
seed: None,
water_color: (0, 0, 255, 255),
no_color: (0, 0, 0, 255),
low_color: (255, 255, 255, 255),
mid_color: (100, 100, 100, 255),
high_color: (50, 50, 50, 255),
)git clone https://github.com/Ztry8/WorldBuilder.git
cd WorldBuilder
cargo run --releaseAfter the work is completed,
there will be a file named map.png in the root directory.
Usually, an open-world game map is created once manually
and doesn't need to be generated every time the game starts (unlike roguelikes),
so the program was made without speed optimizations.
The generation time (size = 1280, size_k = 0.1) is around 0.3 seconds.


