diff options
| author | Aaditya Dhruv <[email protected]> | 2026-01-27 22:35:54 -0600 |
|---|---|---|
| committer | Aaditya Dhruv <[email protected]> | 2026-01-27 22:35:54 -0600 |
| commit | 17cd7420e9d2432d56f9c69c6e4a8ab665ef4b9b (patch) | |
| tree | 7bcfc1d05b9b058240799d714ea0674f5eed58f3 /src/chunk.h | |
| parent | 186889aaa18426d31c268735a4d34b494234f421 (diff) | |
Add World and multi-chunk rendering
- More than 1 chunk can now be rendered with the help of the world
struct
- Block coords are now in world space, not local space
- Engine init code cleaned up for cleaner world/chunk handling
Diffstat (limited to 'src/chunk.h')
| -rw-r--r-- | src/chunk.h | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/chunk.h b/src/chunk.h index 87c33fa..4d06f5f 100644 --- a/src/chunk.h +++ b/src/chunk.h @@ -1,21 +1,27 @@ #pragma once #include "block.h" #include "world.h" -#include "junk/vector.h" #include <stdint.h> -enum biome { - JUNK_BIOME_PLAINS, -}; #define CHUNK_WIDTH 16 #define CHUNK_LENGTH 16 #define CHUNK_HEIGHT 128 +enum biome { + JUNK_BIOME_PLAINS, +}; + + +//NOTE: Forward declare world here. There is a circular dependency between +// chunk and world, and the order in which compiler sees them causes issues. +// World.c compiles -> includes world.h -> first line is include chunk.h -> struct world +// is used here, which messes it up. Forward declare to avoid errors +struct world; struct chunk { struct block* blocks[CHUNK_WIDTH][CHUNK_LENGTH][CHUNK_HEIGHT]; enum biome biome; vec2 coord; }; -int chunk_gen(struct world* world, struct chunk* chunk); +int chunk_gen(struct world* wld, vec2 coord, struct chunk** chunk); int chunk_gen_structures(void* neighbor_data, struct chunk* chunk); int chunk_gen_terrain(void* neighbor_data, struct chunk* chunk); |
