Rename world directory to map
This commit is contained in:
111
engine/breeze/map/map.h
Normal file
111
engine/breeze/map/map.h
Normal file
@@ -0,0 +1,111 @@
|
||||
#ifndef BREEZE_MAP_H
|
||||
#define BREEZE_MAP_H
|
||||
|
||||
#include "tileset.h"
|
||||
#include "../utils/string.h"
|
||||
|
||||
#define BZ_MAX_MAP_LAYERS 8
|
||||
#define BZ_MAX_MAP_TILESETS 8
|
||||
#define BZ_MAP_COLLIDER_DEPTH 2
|
||||
|
||||
|
||||
typedef struct BzTileLayer {
|
||||
i32 id;
|
||||
|
||||
int16_t *data;
|
||||
i32 dataCount;
|
||||
i16 minData;
|
||||
i16 maxData;
|
||||
|
||||
i32 width;
|
||||
i32 height;
|
||||
|
||||
f32 offsetX;
|
||||
f32 offsetY;
|
||||
f32 opacity;
|
||||
|
||||
i32 tilesetIdx;
|
||||
|
||||
void *userData;
|
||||
} BzTileLayer;
|
||||
|
||||
typedef struct BzTileObject {
|
||||
u32 id;
|
||||
BzTileShape shape;
|
||||
|
||||
void *userData;
|
||||
} BzTileObject;
|
||||
|
||||
typedef struct BzTileObjectLayer {
|
||||
BzTileObject *objects;
|
||||
i32 objectCount;
|
||||
} BzTileObjectLayer;
|
||||
|
||||
// Return true, if you want to keep data allocated
|
||||
typedef bool BzTileLayerFunc(BzTileLayer *layer);
|
||||
typedef bool BzTileObjectsFunc(BzTileObjectLayer *objectLayer);
|
||||
|
||||
typedef void BzTileLayerRenderFunc(BzTileLayer *layer);
|
||||
typedef void BzTileObjectsRenderFunc(BzTileObjectLayer *objectLayer);
|
||||
|
||||
typedef struct BzTileLayerDesc {
|
||||
const char *name; // Matches map layer names
|
||||
BzTileLayerFunc *handler;
|
||||
BzTileLayerRenderFunc *renderer;
|
||||
} BzTileLayerDesc;
|
||||
typedef struct BzTileObjectsDesc {
|
||||
const char *name; // Matches map layer names
|
||||
BzTileObjectsFunc *handler;
|
||||
BzTileObjectsRenderFunc *renderer;
|
||||
BzStringHashFunc *hashFunc;
|
||||
} BzTileObjectsDesc;
|
||||
|
||||
typedef struct BzTileMapDesc {
|
||||
const char *path;
|
||||
BzTileset tilesets[BZ_MAX_MAP_TILESETS];
|
||||
|
||||
BzTileLayerDesc layers[BZ_MAX_MAP_LAYERS];
|
||||
BzTileObjectsDesc objectLayers[BZ_MAX_MAP_LAYERS];
|
||||
} BzTileMapDesc;
|
||||
|
||||
typedef struct BzTileCollider {
|
||||
BzTileShape shapes[BZ_MAP_COLLIDER_DEPTH];
|
||||
} BzTileCollider;
|
||||
|
||||
typedef struct BzTileMap {
|
||||
Color backgroundColor;
|
||||
|
||||
i32 width;
|
||||
i32 height;
|
||||
i32 tileWidth;
|
||||
i32 tileHeight;
|
||||
|
||||
BzTileCollider *colliderMap;
|
||||
i32 collidersCount;
|
||||
|
||||
BzTileLayer layers[BZ_MAX_MAP_LAYERS];
|
||||
i32 layerCount;
|
||||
|
||||
BzTileObjectLayer objectLayers[BZ_MAX_MAP_LAYERS];
|
||||
i32 objectLayerCount;
|
||||
|
||||
BzTileset tilesets[BZ_MAX_MAP_TILESETS];
|
||||
i32 tilesetCount;
|
||||
|
||||
bool isValid;
|
||||
} BzTileMap;
|
||||
|
||||
extern BzTileMap BZ_TILEMAP_INVALID;
|
||||
|
||||
int16_t bzTileLayerGetTile(BzTileLayer *layer, i32 x, i32 y);
|
||||
|
||||
BzTileMap bzTileMapCreate(const BzTileMapDesc *desc);
|
||||
void bzTileMapDestroy(BzTileMap *tilemap);
|
||||
|
||||
void bzTileMapDraw(BzTileMap *map);
|
||||
void bzTileMapDrawColliders(BzTileMap *map);
|
||||
BzTileCollider bzTileMapGetCollider(BzTileMap *map, i32 x, i32 y);
|
||||
|
||||
|
||||
|
||||
#endif //BREEZE_MAP_H
|
||||
Reference in New Issue
Block a user