More on terrain generation
The map needs to be long on the horizontal axis, and have mountain ranges that cut across laterally to restrict the player's movement. Mapgen works by creating an initial hightmap so we can use libtcod's convenient heightmap functions, and then assigning terrain based on that. Some details are from memory of what I started on for 7DRL last year, but the basic terrain generation is quite different.
- Start with some FBM noise (heightmap_add_fbm).
- Carve mountain ranges: Choose equally spaced x-axis positions for the ranges. For each, path find from the top of the map to the bottom over the existing noise height to make a spine that cuts roughly vertically across the map. Go along the spine path, generating circular hills (heightmap_dig_hill) at random x-offsets from the spine. Hill radius is larger closer to the spine.
- Carve lake basins: Similar to mountain ranges, but as a spine we choose two points close to each other and pathfind between them, and we dig out circular pits (heightmap_dig_hill).
- Smooth the map with some averaging (heightmap_kernel_transform) and then simulating erosion (heightmap_rain_erosion).
- Assign basic terrain of water/flat/mountains based on heights.
- Add river terrain: Pathfind from lake basin pit centres to random points. Draw water along path, stopping on various conditions for plausibility. To avoid circular rivers, do pathfinding on a copy of of the hightmap and add hills along rivers as we make them.
- Make some guaranteed paths from start to end: Pathfind from start to end through some random midpoints, removing mountains and water on the way.
- Add cities at random points.
- Add patchy roads between random cities.
Leave a comment
Log in with your itch.io account to leave a comment.