Add collider map

This commit is contained in:
2023-11-09 09:32:02 +01:00
parent fa79af2a17
commit 913a365a21
3 changed files with 90 additions and 5 deletions

View File

@@ -6,6 +6,7 @@
#define BZ_MAX_MAP_LAYERS 8
#define BZ_MAX_MAP_TILESETS 8
#define BZ_MAP_COLLIDER_DEPTH 3
typedef struct BzTileLayer {
@@ -58,6 +59,10 @@ typedef struct BzTileMapDesc {
BzTileObjectsDesc objectLayers[BZ_MAX_MAP_LAYERS];
} BzTileMapDesc;
typedef struct BzTileCollider {
BzTileShape shapes[BZ_MAP_COLLIDER_DEPTH];
} BzTileCollider;
typedef struct BzTileMap {
Color backgroundColor;
@@ -66,6 +71,9 @@ typedef struct BzTileMap {
i32 tileWidth;
i32 tileHeight;
BzTileCollider *colliderMap;
i32 collidersCount;
BzTileLayer layers[BZ_MAX_MAP_LAYERS];
i32 layerCount;
@@ -86,7 +94,9 @@ BzTileMap bzTileMapCreate(const BzTileMapDesc *desc);
void bzTileMapDestroy(BzTileMap *tilemap);
void bzTileMapDraw(BzTileMap *map);
void bzTileMapDrawColliders(BzTileMap *map);
bool bzTileMapCanPlace(BzTileMap *map, i32 tileX, i32 tileY, i32 sizeX, i32 sizeY);
BzTileCollider bzTileMapGetCollider(BzTileMap *map, i32 x, i32 y);