Functions
mk_autotile_maskfunction
uint32_t mk_autotile_mask(const bool neighbours[MK_NEIGHBOUR_COUNT], mk_autotile_kind kind)
Canonical variant index for a neighbourhood.
Pure function of the neighbour bits, exposed so callers can drive their own tile selection without owning a tilemap. Returns < 16 for EDGE_16 and < 47 for BLOB_47.
| Parameter | Type | Description |
|---|
neighbours | const bool | Occupancy in mk_neighbour order. |
kind | mk_autotile_kind | Autotile rule used to canonicalize the mask |
Returns The resulting value.
mk_tilemap_autotilefunction
mk_result mk_tilemap_autotile(mk_tilemap_t map, uint32_t layer, const mk_terrain_desc *terrain)
Rewrite every non-empty tile of a layer to the terrain variant that fits.
| Parameter | Type | Description |
|---|
map | mk_tilemap_t | Value for map. |
layer | uint32_t | Value for layer. |
terrain | const mk_terrain_desc * | Value for terrain. |
Returns MK_SUCCESS or an error result.
mk_tilemap_clear_layerfunction
void mk_tilemap_clear_layer(mk_tilemap_t map, uint32_t layer)
Clear the layer for the tilemap.
| Parameter | Type | Description |
|---|
map | mk_tilemap_t | Value for map. |
layer | uint32_t | Value for layer. |
mk_tilemap_createfunction
mk_tilemap_t mk_tilemap_create(const mk_tilemap_desc *desc)
Create tilemap.
| Parameter | Type | Description |
|---|
desc | const mk_tilemap_desc * | Configuration descriptor. |
Returns The resulting handle or value.
mk_tilemap_destroyfunction
void mk_tilemap_destroy(mk_tilemap_t map)
Destroy the tilemap.
| Parameter | Type | Description |
|---|
map | mk_tilemap_t | Value for map. |
mk_tilemap_drawfunction
uint32_t mk_tilemap_draw(mk_tilemap_t map, mk_canvas_t canvas, const mk_camera2d *camera)
Draw every visible layer into an open canvas.
Must be called between mk_begin_pass()/mk_end_pass() on a painter-ordered 2D pass, with the canvas in drawing mode. Pass the camera to cull off-screen chunks, or NULL to draw them all.
| Parameter | Type | Description |
|---|
map | mk_tilemap_t | Value for map. |
canvas | mk_canvas_t | Value for canvas. |
camera | const mk_camera2d * | Value for camera. |
Returns Number of chunks submitted (0 when fully culled or unavailable).
mk_tilemap_get_tilefunction
mk_tile_t mk_tilemap_get_tile(mk_tilemap_t map, uint32_t layer, uint32_t x, uint32_t y)
Get tile from the tilemap.
| Parameter | Type | Description |
|---|
map | mk_tilemap_t | Value for map. |
layer | uint32_t | Value for layer. |
x | uint32_t | Value for x. |
y | uint32_t | Value for y. |
Returns The resulting handle or value.
mk_tilemap_heightfunction
uint32_t mk_tilemap_height(mk_tilemap_t map)
Perform the tilemap height operation.
| Parameter | Type | Description |
|---|
map | mk_tilemap_t | Value for map. |
Returns The resulting value.
mk_tilemap_is_validfunction
bool mk_tilemap_is_valid(mk_tilemap_t map)
Test whether the tilemap is valid.
| Parameter | Type | Description |
|---|
map | mk_tilemap_t | Value for map. |
Returns True when the condition holds.
mk_tilemap_layer_countfunction
uint32_t mk_tilemap_layer_count(mk_tilemap_t map)
Perform the tilemap layer count operation.
| Parameter | Type | Description |
|---|
map | mk_tilemap_t | Value for map. |
Returns The resulting value.
mk_tilemap_layer_visiblefunction
bool mk_tilemap_layer_visible(mk_tilemap_t map, uint32_t layer)
Perform the tilemap layer visible operation.
| Parameter | Type | Description |
|---|
map | mk_tilemap_t | Value for map. |
layer | uint32_t | Value for layer. |
Returns True when the operation succeeds.
mk_tilemap_load_tiledfunction
mk_tilemap_t mk_tilemap_load_tiled(const char *tmj_path, const mk_tileset_desc *tileset_override)
Load an orthogonal map from Tiled's JSON export (.tmj).
Handles tile layers with array or CSV data, embedded and external (.tsj) tilesets, and the flip bits Tiled packs into each GID. Returns MK_TILEMAP_INVALID for infinite maps, isometric/hexagonal orientations, and base64/compressed layer data rather than misreading them.
| Parameter | Type | Description |
|---|
tmj_path | const char * | Path to the .tmj file. |
tileset_override | const mk_tileset_desc * | Use this tileset instead of the one named in the file; pass NULL to resolve the file's own tileset image relative to the .tmj. |
Returns The resulting handle or value.
mk_tilemap_set_layer_visiblefunction
void mk_tilemap_set_layer_visible(mk_tilemap_t map, uint32_t layer, bool visible)
Set layer visible on the tilemap.
| Parameter | Type | Description |
|---|
map | mk_tilemap_t | Value for map. |
layer | uint32_t | Value for layer. |
visible | bool | Value for visible. |
mk_tilemap_set_tilefunction
mk_result mk_tilemap_set_tile(mk_tilemap_t map, uint32_t layer, uint32_t x, uint32_t y, mk_tile_t tile)
Set tile on the tilemap.
| Parameter | Type | Description |
|---|
map | mk_tilemap_t | Value for map. |
layer | uint32_t | Value for layer. |
x | uint32_t | Value for x. |
y | uint32_t | Value for y. |
tile | mk_tile_t | Value for tile. |
Returns MK_SUCCESS or an error result.
mk_tilemap_widthfunction
uint32_t mk_tilemap_width(mk_tilemap_t map)
Perform the tilemap width operation.
| Parameter | Type | Description |
|---|
map | mk_tilemap_t | Value for map. |
Returns The resulting value.