Remove multiple colliders, add spatial index component

This commit is contained in:
2023-11-17 15:13:30 +01:00
parent 208cdc6b6f
commit 021df6d77a
11 changed files with 122 additions and 95 deletions

View File

@@ -6,7 +6,6 @@
#define BZ_MAP_MAX_LAYERS 8
#define BZ_MAP_MAX_TILESETS 8
#define BZ_MAP_COLLIDER_DEPTH 2
typedef struct BzTileLayer BzTileLayer;
typedef struct BzTileObject BzTileObject;
@@ -22,6 +21,7 @@ extern BzTileObjectGroupRenderFunc BZ_TILE_OBJECTS_SKIP_RENDER;
typedef struct BzTileLayerDesc {
const char *name; // Matches map layer names
BzTileLayerRenderFunc renderer;
bool applyColliders;
} BzTileLayerDesc;
typedef struct BzTileObjectsDesc {
const char *name; // Matches map layer names
@@ -31,6 +31,7 @@ typedef struct BzTileObjectsDesc {
typedef struct BzTileMapDesc {
const char *path;
bool generateColliderMap;
BzTileset tilesets[BZ_MAP_MAX_TILESETS];
BzTileLayerDesc layers[BZ_MAP_MAX_LAYERS];
@@ -76,10 +77,6 @@ typedef struct BzTileObjectGroup {
} BzTileObjectGroup;
typedef struct BzTileCollider {
BzTileShape shapes[BZ_MAP_COLLIDER_DEPTH];
} BzTileCollider;
typedef struct BzTileMap {
Color backgroundColor;
@@ -88,8 +85,7 @@ typedef struct BzTileMap {
i32 tileWidth;
i32 tileHeight;
BzTileCollider *colliderMap;
i32 collidersCount;
BzTileShape *colliderMap;
BzTileLayer layers[BZ_MAP_MAX_LAYERS];
i32 layerCount;
@@ -128,8 +124,8 @@ BzTileObjectGroup *bzTileMapGetObjects(BzTileMap *map, i32 slotID);
void bzTileMapDraw(BzTileMap *map);
void bzTileMapDrawColliders(BzTileMap *map);
BzTileCollider bzTileMapGetCollider(BzTileMap *map, i32 x, i32 y);
void bzTileMapUpdateCollider(BzTileMap *map, i32 x, i32 y);
BzTileShape bzTileMapGetCollider(BzTileMap *map, i32 x, i32 y);
void bzTileMapUpdateColliders(BzTileMap *map, i32 x, i32 y, i32 sizeX, i32 sizeY);