Add support for objects with tiles

This commit is contained in:
2023-11-11 09:21:59 +01:00
parent b46663bf88
commit 3c8254c6f6
10 changed files with 101 additions and 25 deletions

View File

@@ -4,8 +4,8 @@
#include "tileset.h"
#include "../utils/string.h"
#define BZ_MAX_MAP_LAYERS 8
#define BZ_MAX_MAP_TILESETS 8
#define BZ_MAP_MAX_LAYERS 8
#define BZ_MAP_MAX_TILESETS 8
#define BZ_MAP_COLLIDER_DEPTH 2
typedef struct BzTileLayer BzTileLayer;
@@ -30,10 +30,10 @@ typedef struct BzTileObjectsDesc {
typedef struct BzTileMapDesc {
const char *path;
BzTileset tilesets[BZ_MAX_MAP_TILESETS];
BzTileset tilesets[BZ_MAP_MAX_TILESETS];
BzTileLayerDesc layers[BZ_MAX_MAP_LAYERS];
BzTileObjectsDesc objectGroups[BZ_MAX_MAP_LAYERS];
BzTileLayerDesc layers[BZ_MAP_MAX_LAYERS];
BzTileObjectsDesc objectGroups[BZ_MAP_MAX_LAYERS];
} BzTileMapDesc;
typedef struct BzTileLayer {
@@ -59,12 +59,16 @@ typedef struct BzTileLayer {
typedef struct BzTileObject {
u32 id;
BzTile gid;
BzTileShape shape;
} BzTileObject;
typedef struct BzTileObjectGroup {
BzTileObject *objects;
i32 objectCount;
BzTile minGID;
BzTile maxGID;
i32 tilesetIdx;
BzTileObjectsDesc desc;
bool hasOwnership;
@@ -86,13 +90,13 @@ typedef struct BzTileMap {
BzTileCollider *colliderMap;
i32 collidersCount;
BzTileLayer layers[BZ_MAX_MAP_LAYERS];
BzTileLayer layers[BZ_MAP_MAX_LAYERS];
i32 layerCount;
BzTileObjectGroup objectGroups[BZ_MAX_MAP_LAYERS];
BzTileObjectGroup objectGroups[BZ_MAP_MAX_LAYERS];
i32 objectGroupCount;
BzTileset tilesets[BZ_MAX_MAP_TILESETS];
BzTileset tilesets[BZ_MAP_MAX_TILESETS];
i32 tilesetCount;
bool isValid;