Estella 0.113.0
A fast 2D and 3D game engine powered by WebAssembly and ECS
Loading...
Searching...
No Matches
TilemapBindings.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
23#pragma once
24
25#ifdef ES_ENABLE_TILEMAP
26
27#include "../core/Types.hpp"
28
29#include <cstdint>
30#include <string>
31
32namespace esengine {
33
34// — Layer lifecycle —
35
36void tilemap_initLayer(u32 entity, u32 width, u32 height, f32 tileWidth, f32 tileHeight);
37void tilemap_initInfinite(u32 entity, f32 tileWidth, f32 tileHeight);
38void tilemap_initInfiniteLayer(u32 entity, f32 tileWidth, f32 tileHeight);
39void tilemap_destroyLayer(u32 entity);
40bool tilemap_hasLayer(u32 entity);
41u32 tilemap_getEditRevision(u32 entity);
42u32 tilemap_getGeneration(u32 entity);
43// Rows are [signed chunk x, signed chunk y, revision], three u32 words each.
44// Returns the required row count without writing when capacity is too small.
45u32 tilemap_readChunkIndex(u32 entity, uintptr_t rowsPtr, u32 capacity);
46bool tilemap_readChunkTiles(u32 entity, i32 chunkX, i32 chunkY, uintptr_t tilesPtr, u32 capacity);
47
48// — Tiles —
49
50void tilemap_setTile(u32 entity, i32 x, i32 y, u32 tileId);
51u32 tilemap_getTile(u32 entity, i32 x, i32 y);
52void tilemap_fillRect(u32 entity, i32 x, i32 y, u32 w, u32 h, u32 tileId);
53void tilemap_setTiles(u32 entity, uintptr_t tilesPtr, u32 count);
54void tilemap_setChunkTiles(u32 entity, i32 chunkX, i32 chunkY,
55 uintptr_t tilesPtr, u32 width, u32 height);
57void tilemap_removeChunk(u32 entity, i32 chunkX, i32 chunkY);
58void tilemap_flipTile(u32 entity, i32 x, i32 y, bool flipH, bool flipV, bool flipD);
59void tilemap_rotateTile(u32 entity, i32 x, i32 y, i32 degrees);
60
61// — Rendering —
62
63void tilemap_setTilesets(u32 entity, uintptr_t dataPtr, u32 count);
64void tilemap_setRenderProps(u32 entity, u32 textureHandle, u32 tilesetColumns,
65 f32 uvTileW, f32 uvTileH,
66 i32 sortLayer, f32 depth,
67 f32 parallaxX, f32 parallaxY);
68void tilemap_setTint(u32 entity, f32 r, f32 g, f32 b, f32 a, f32 opacity);
69void tilemap_setVisible(u32 entity, bool visible);
70void tilemap_setOriginEntity(u32 layerKey, u32 originEntity);
71
72// — Grid shape (orthogonal / isometric / staggered / hexagonal) —
73
74void tilemap_setGridType(u32 entity, u32 type);
75void tilemap_setHexParams(u32 entity, f32 sideLength, u32 staggerAxisX, u32 staggerIndexEven);
76
77// Both answer a pair of floats in a shared static buffer, so the offset is stable
78// and the byte count is fixed.
79// @heapreturn 2 * sizeof(float)
80uintptr_t tilemap_tileToWorld(u32 entity, i32 tx, i32 ty, f32 originX, f32 originY);
81// @heapreturn 2 * sizeof(float)
82uintptr_t tilemap_worldToTile(u32 entity, f32 wx, f32 wy, f32 originX, f32 originY);
83
84// — Animated tiles —
85
86void tilemap_setTileAnimation(u32 entity, u32 tileId, uintptr_t framesPtr, u32 frameCount);
87void tilemap_clearTileAnimations(u32 entity);
88void tilemap_advanceAnimations(u32 entity, f32 dtMs);
89
90// — Tile properties + chunk serialization (the editor's tools and .estileset) —
91
92void tilemap_setTileProperty(u32 entity, u32 tileId,
93 const std::string& key, const std::string& value);
94std::string tilemap_getTileProperty(u32 entity, i32 x, i32 y, const std::string& key);
95std::string tilemap_exportChunks(u32 entity);
96bool tilemap_importChunks(u32 entity, const std::string& encoded);
97
98} // namespace esengine
99
100#endif // ES_ENABLE_TILEMAP
Core type definitions and utilities for ESEngine.
std::int32_t i32
Signed 32-bit integer.
Definition Types.hpp:54
std::uint32_t u32
Unsigned 32-bit integer.
Definition Types.hpp:45
float f32
32-bit floating point
Definition Types.hpp:59