#pragma once #include #include "tile.h" #include "../file/asset.h" #include "../input/input.h" #include "../util/string.h" /** When loading a chunk, how many chars to offset (ASCII char to byte) */ #define CHUNK_TILE_LOAD_ASCII 48 /** Width (in tiles) of chunks. */ #define CHUNK_WIDTH 16 /** Heihgt (in tiles) of chunks. */ #define CHUNK_HEIGHT 16 /** Depth (in tiles) of chunks. */ #define CHUNK_DEPTH 8 /** Count of tiles in the chunk. */ #define CHUNK_TILE_COUNT CHUNK_WIDTH*CHUNK_HEIGHT*CHUNK_DEPTH /** Representation of a chunk, a group of tiles that can be buffered around. */ typedef struct { /** Position (in absolute chunk coordinates) of this chunk */ int32_t x, y, z; /** Array of tiles within the chunk */ tileid_t tiles[CHUNK_TILE_COUNT]; /** Ready to be rendered chunk 3d primitive */ primitive_t *primitive; } chunk_t; /** * Loads a given chunk. * * @param chunk The chunk to load. * @param x X of the chunk. * @param y Y of the chunk. * @param z Z of the chunk. */ void chunkLoad(chunk_t *chunk, tilemap_t *tilemap, int32_t x, int32_t y, int32_t z ); /** * Unload a given chunk. * * @param chunk Chunk to unload. */ void chunkUnload(chunk_t *chunk);