From 8150b91d4076d15f8df5cd66acc1b8076a2ee1a9 Mon Sep 17 00:00:00 2001 From: Aaditya Dhruv Date: Fri, 30 Jan 2026 00:17:39 -0600 Subject: Update chunk rendering, improve chunk loading - On world_init, LOAD_CHUNK amount of chunks are preloaded - Chunks are loaded around the player's current chunk, in a square shape. The size of the shape is controlled by CHUNK_DISTANCE - Allow chunks struct to be independent of a position. We load a chunk TO a position in the world chunk grid (x, y). This allows us to "wrap" chunks, so we have an endless world, but we are really just wrapping around --- src/world.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/world.h') diff --git a/src/world.h b/src/world.h index c65a1d0..ec0328b 100644 --- a/src/world.h +++ b/src/world.h @@ -1,8 +1,8 @@ #pragma once #include "chunk.h" #include -#define WORLD_LENGTH 32 -#define WORLD_WIDTH 32 +#define WORLD_LENGTH 6 +#define WORLD_WIDTH 6 struct world { struct chunk* chunks[WORLD_WIDTH][WORLD_LENGTH]; @@ -11,4 +11,5 @@ struct world { int world_init(int32_t seed, struct world** world); int world_save(int32_t seed); -int world_get_chunk(struct world* world, vec2 coord, struct chunk** chunk); +int world_get_chunk(struct world* world, int coord[2], struct chunk** chunk); +void world_get_chunk_real_coord(struct world* world, vec2 coord, int out[2]); -- cgit