Dawn/src/engine/world/chunk.h
2021-04-05 13:58:17 +10:00

56 lines
1.1 KiB
C

// Copyright (c) 2021 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include <stdint.h>
#include "../display/primitive.h"
#include "../display/shader.h"
#include "../display/spritebatch.h"
#define CHUNK_WIDTH 3
#define CHUNK_HEIGHT CHUNK_WIDTH
#define CHUNK_DEPTH CHUNK_HEIGHT
typedef uint8_t tile_t;
typedef struct {
/** Absolute X Y Z chunklist coordinates */
int32_t x, y, z;
/** Tiles within the chunk */
tile_t *tiles;
/** Sprite Batch for holding static tiles */
spritebatch_t *batch;
} chunk_t;
/**
* Initializes a chunk for the first time.
*
* @param chunk Pointer to the chunk to initialize.
*/
void chunkCreate(chunk_t *chunk);
/**
* Loads a given chunk into the memory specified.
*
* @param chunk Chunk to load into.
* @param x X of the chunk.
* @param y Y of the chunk.
* @param z Z of the chunk.
*/
void chunkLoad(chunk_t *chunk, int32_t x, int32_t y, int32_t z);
/**
* Unload a given chunk.
*
* @param chunk Chunk to unload.
*/
void chunkUnload(chunk_t *chunk);
void chunkRender(chunk_t *chunk, shader_t *shader);