14.1. Creating a heightmap
Creating an empty map
As with other modules, you have to create a heightmap object first :
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.
TCODHeightMap::TCODHeightMap(int w, int h)
typedef struct {
int w,h;
float *values;
} TCOD_heightmap_t;
TCOD_heightmap_t *TCOD_heightmap_new(int w,int h)
heightmap_new(w,h)
TCODHeightMap::TCODHeightMap(int w, int h)
Parameter | Description |
---|---|
w,h | The width and height of the heightmap. |
Example:
TCODHeightMap myMap(50,50);
TCOD_heightmap_t *my_map=TCOD_heightmap_new(50,50);
map=libtcod.heightmap_new(50,50)
print map.w, map.h
Destroying a heightmap
To release the resources used by a heightmap, destroy it with :
TCODHeightMap::~TCODHeightMap()
void TCOD_heightmap_delete(TCOD_heightmap_t *hm)
heightmap_delete(hm)
void TCODHeightMap::Dispose()
Parameter | Description |
---|---|
hm | In the C version, the address of the heightmap struct returned by the creation function. |