do you know why there isn't anything rendering: #include "raylib.h" #include "uthash.h"…
- User
do you know why there isn't anything rendering: #include "raylib.h" #include "uthash.h" #define FNL_IMPL #include "FastNoiseLite.h"
#define CHUNK_SIZE 16 #define CHUNK_HEIGHT 128 #define RENDER_DISTANCE 3
typedef struct { unsigned char blocks[CHUNK_SIZE][CHUNK_HEIGHT][CHUNK_SIZE]; } Chunk;
typedef struct { int x, z; Chunk* chunk; UT_hash_handle hh; } ChunkPosition;
ChunkPosition* chunks = NULL;
Chunk* create_chunk() { Chunk* chunk = (Chunk*)malloc(sizeof(Chunk)); memset(chunk, 0, sizeof(Chunk)); return chunk; }
void add_chunk(int x, int z, Chunk* chunk) { ChunkPosition* cp = (ChunkPosition*)malloc(sizeof(ChunkPosition)); cp->x = x; cp->z = z; cp->chunk = chunk; HASH_ADD(hh, chunks, x, sizeof(int) * 2, cp); }
Chunk* get_chunk(int x, int z) { ChunkPosition* cp; HASH_FIND(hh, chunks, &x, sizeof(int) * 2, cp); return cp ? cp->chunk : NULL; }
void generate_chunk(int chunk_x, int chunk_z, fnl_state* noise) { Chunk* chunk = create_chunk();
codefor (int x = 0; x < CHUNK_SIZE; x++) { for (int z = 0; z < CHUNK_SIZE; z++) { int world_x = chunk_x * CHUNK_SIZE + x; int world_z = chunk_z * CHUNK_SIZE + z; float noiseValue = fnlGetNoise2D(noise, world_x * 0.02f, world_z * 0.02f); int height = (int)((noiseValue + 1) * 32) + 32; // Scale noise to 32-96 range for (int y = 0; y < CHUNK_HEIGHT; y++) { if (y < height) { chunk->blocks[x][y][z] = 1; // 1 represents a solid block } else { chunk->blocks[x][y][z] = 0; // 0 represents air } } } } add_chunk(chunk_x, chunk_z, chunk);}
void render_chunk(int chunk_x, int chunk_z) { Chunk* chunk = get_chunk(chunk_x, chunk_z); if (!chunk) return;
code Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.