BUILDING AN ISLAND

The base of the  world generator

The goal

In TCOD, the player will have a huge world to explore. This world will contain cities, caves and dungeons, mountains, rivers, ... But before building all this, we need a terrain. To avoid map border issues, the terrain should be an island. So we start by generating a low scale island (currently 50x50 cells, each cell represents a 100x100 region in the real game).

Building hills

So we start with an integer array of 50x50 that will represent the island heightmap. We start by filling the array with 0, then build a first hill :

  • choose a random radius for the hill (smaller enough to stay in the map, for example < 10)
  • choose the hill center inside the map at xh,yh (we want water all around the island so the hill should not cross the map borders)
  • for each cell x,y, calculate the hill height = radius*radius - ( x - xh )*( x - xh ) - (y - yh)*(y - yh);
  • if the hill height is positive, add it to the cell
Great ! This is what we get :

Now, build more hills... After 5 iterations :

After 20 iterations :

Give it a natural look

It takes shape, but still has an unnatural look. We could iterate a lot more (100 or 1000 hills) to get a really smooth landscape but this would take some time and don't forget this is a low scale map, so we don't need high quality. To reduce the visibility of the hill borders, we can blur the picture and/or add noise :

This is called Fractionnal Brownian Motion or fbm. Despite its scary name, it's just a fractal sum of perlin noise textures. More information on perlin noise can be found starting with this link :

When we add the 20 hills texture and the fbm, we get the final island heightmap :

Now we replace the grayscale colors by an appropriate gradient (blue for water, brown for sand, green for grass, white for snow) :

This is the current low-scale map at it is shown in the game engine.
The next article will show how to generate the real size map from this low-scale version.

PAGES

Home

News

Forums 

The Doryen library

The Doryen Arena 

Developer articles

A generic items system

Building an island

Minimap interpolation

World storage

Basic dungeon generation

Dungeon morphing

Visibility Determination

Game designer articles

Inventory

The trading system

Stealth gameplay

Dialogs

Leveling system

Dynamic map


LINKS

Temple of the roguelike

Roguebasin

Dungeon dweller

Roguelike Dev newsgroup