< index < 15. Heightmap toolkit | ===================================== 15.1 Creating a heightmap ===================================== | > 15.2 Basic operations

As with other modules, you have to create a heightmap object first :

    C++ : TCODHeightMap::TCODHeightMap(int w, int h)
    C   : typedef struct {
              int w,h;
              float *values;
          } TCOD_heightmap_t;
          TCOD_heightmap_t *TCOD_heightmap_new(int w,int h)
    Py  : heightmap_new(w,h)

Parameter | Description
--- | ---
w,h | The width and height of the heightmap.

Note that whereas most other modules use opaque structs, the TCOD_heightmap_t fields can be freely accessed. Thus, the TCOD_heightmap_new function returns a TCOD_heightmap_t pointer, not a TCOD_heightmap_t. The w and h fields should not be modified after the heightmap creation. The newly created heightmap is filled with 0.0 values.
Example :

    C++ : TCODHeightMap myMap(50,50);
    C   : TCOD_heightmap_t *my_map=TCOD_heightmap_new(50,50);
    Py  : map=libtcod.heightmap_new(50,50)
          print map.w, map.h