Convert buildings to entities (partially)
This commit is contained in:
@@ -19,9 +19,15 @@ bool bzTileObjectsClear(BzTileObjectGroup *objectGroup, BzTileObject *objects, i
|
||||
BzTileLayerFunc BZ_TILE_LAYER_CLEAR = bzTileLayerClear;
|
||||
BzTileObjectsFunc BZ_TILE_OBJECTS_CLEAR = bzTileObjectsClear;
|
||||
|
||||
int16_t bzTileLayerGetTile(BzTileLayer *layer, i32 x, i32 y) {
|
||||
BzTile bzTileLayerGetTile(BzTileLayer *layer, i32 x, i32 y) {
|
||||
return layer->data[layer->width * y + x];
|
||||
}
|
||||
BzTileset *bzTileLayerGetTileset(BzTileMap *map, BzTileLayer *layer) {
|
||||
i32 idx = layer->tilesetIdx;
|
||||
if (idx < 0 || idx >= map->tilesetCount)
|
||||
return NULL;
|
||||
return &map->tilesets[idx];
|
||||
}
|
||||
|
||||
static void handleTileLayer(BzTileLayer *layer, cute_tiled_layer_t *cuteLayer) {
|
||||
layer->id = cuteLayer->id;
|
||||
@@ -313,6 +319,15 @@ static void drawObjectLayer(BzTileObjectGroup *objectLayer) {
|
||||
}
|
||||
}
|
||||
|
||||
BzTileLayer *bzTileMapGetLayer(BzTileMap *map, i32 slotID) {
|
||||
BZ_ASSERT(slotID >= 0 && slotID < map->layerCount);
|
||||
return &map->layers[slotID];
|
||||
}
|
||||
BzTileObjectGroup *bzTileMapGetObjects(BzTileMap *map, i32 slotID) {
|
||||
BZ_ASSERT(slotID >= 0 && slotID < map->objectGroupCount);
|
||||
return &map->objectGroups[slotID];
|
||||
}
|
||||
|
||||
void bzTileMapDraw(BzTileMap *map) {
|
||||
for (i32 i = 0; i < map->layerCount; i++) {
|
||||
BzTileLayer *layer = map->layers + i;
|
||||
|
||||
@@ -97,14 +97,15 @@ typedef struct BzTileMap {
|
||||
|
||||
extern BzTileMap BZ_TILEMAP_INVALID;
|
||||
|
||||
// Return true, if you want to override data (you are responsible for cleanup, if you override)
|
||||
// Return true, if you want to override data pointer (you are responsible for cleanup, if you override)
|
||||
typedef bool (*BzTileLayerFunc)(BzTileLayer *layer, BzTile *data, i32 dataCount);
|
||||
typedef bool (*BzTileObjectsFunc)(BzTileObjectGroup *objectGroup, BzTileObject *objects, i32 objectsCount);
|
||||
|
||||
extern BzTileLayerFunc BZ_TILE_LAYER_CLEAR;
|
||||
extern BzTileObjectsFunc BZ_TILE_OBJECTS_CLEAR;
|
||||
|
||||
int16_t bzTileLayerGetTile(BzTileLayer *layer, i32 x, i32 y);
|
||||
BzTile bzTileLayerGetTile(BzTileLayer *layer, i32 x, i32 y);
|
||||
BzTileset *bzTileLayerGetTileset(BzTileMap *map, BzTileLayer *layer);
|
||||
|
||||
BzTileMap bzTileMapCreate(const BzTileMapDesc *desc);
|
||||
void bzTileMapDestroy(BzTileMap *map);
|
||||
@@ -112,6 +113,9 @@ void bzTileMapDestroy(BzTileMap *map);
|
||||
void bzTileMapOverrideLayer(BzTileMap *map, i32 slotID, BzTileLayerFunc func);
|
||||
void bzTileMapOverrideObjectGroup(BzTileMap *map, i32 slotID, BzTileObjectsFunc func);
|
||||
|
||||
BzTileLayer *bzTileMapGetLayer(BzTileMap *map, i32 slotID);
|
||||
BzTileObjectGroup *bzTileMapGetObjects(BzTileMap *map, i32 slotID);
|
||||
|
||||
void bzTileMapDraw(BzTileMap *map);
|
||||
void bzTileMapDrawColliders(BzTileMap *map);
|
||||
BzTileCollider bzTileMapGetCollider(BzTileMap *map, i32 x, i32 y);
|
||||
|
||||
@@ -78,6 +78,11 @@ BzTileset bzTilesetCreate(const BzTilesetDesc *desc) {
|
||||
return tileset;
|
||||
}
|
||||
|
||||
BzTile bzTilesetGetTile(BzTileset *tileset, BzTile tile) {
|
||||
tile = tile - tileset->startID;
|
||||
BZ_ASSERT(tile >= tile && tile < tileset->tileCount);
|
||||
return tile;
|
||||
}
|
||||
Rectangle bzTilesetGetTileRegion(BzTileset *tileset, BzTile tileID) {
|
||||
tileID = tileID - tileset->startID;
|
||||
if (tileID < 0 || tileID >= tileset->tileCount) {
|
||||
|
||||
@@ -46,6 +46,7 @@ extern BzTileset BZ_TILESET_INVALID;
|
||||
|
||||
BzTileset bzTilesetCreate(const BzTilesetDesc *desc);
|
||||
|
||||
BzTile bzTilesetGetTile(BzTileset *tileset, BzTile tile);
|
||||
Rectangle bzTilesetGetTileRegion(BzTileset *tileset, BzTile tileID);
|
||||
BzTileShape bzTilesetGetTileCollider(BzTileset *tileset, BzTile tileID);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user