Skip to content

Ztry8/WorldBuilder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WorldBuilder

GitHub last commit License

Lightweight and simple heightmap generator for open-world game landscapes!

screenshot

About generator

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

Configuration

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),
)

Building

git clone https://github.com/Ztry8/WorldBuilder.git
cd WorldBuilder
cargo run --release

After the work is completed,
there will be a file named map.png in the root directory.

Time

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.

Results

size = 1280; size_k = 0.1

screenshot

size = 1280; size_k = 0.05

screenshot

About

Lightweight and simple heightmap generator for open-world game landscapes

Topics

Resources

License

Stars

Watchers

Forks

Contributors

Languages