diff --git a/code/game/src/gen/texgen.c b/code/game/src/gen/texgen.c index b4683d1..841d29a 100644 --- a/code/game/src/gen/texgen.c +++ b/code/game/src/gen/texgen.c @@ -14,6 +14,13 @@ Texture2D LoadImageEco(const char *name) { Texture2D texgen_build_sprite(asset_id id) { switch (id) { + case ASSET_EMPTY: { + Image img = GenImageColor(1, 1, PINK); + Texture2D tex = LoadTextureFromImage(img); + UnloadImage(img); + return tex; + }break; + case ASSET_DEMO_ICEMAKER: return LoadImageEco("demo_icemaker"); // NOTE(zaklaus): blocks @@ -41,6 +48,4 @@ Texture2D texgen_build_sprite(asset_id id) { return tex; }break; } - - ZPL_PANIC("unreachable code"); } diff --git a/code/game/src/world/blocks_list.c b/code/game/src/world/blocks_list.c index 716a1ee..369f082 100644 --- a/code/game/src/world/blocks_list.c +++ b/code/game/src/world/blocks_list.c @@ -6,7 +6,7 @@ } static block blocks[] = { - BLOCK(ASSET_EMPTY, 0, ' ', .drag = 1.0f, .friction = 1.0f), + BLOCK(ASSET_EMPTY, 0, 'E'), BLOCK(ASSET_GROUND, 0, '.', .drag = 1.0f, .friction = 1.0f), BLOCK(ASSET_DIRT, 0, ',', .drag = 2.1f , .friction = 1.0f), BLOCK(ASSET_WALL, BLOCK_FLAG_COLLISION, '#', .drag = 1.0f , .friction = 1.0f, .bounce = 1.0f), diff --git a/code/game/src/world/world.c b/code/game/src/world/world.c index 0c99f37..6f63be0 100644 --- a/code/game/src/world/world.c +++ b/code/game/src/world/world.c @@ -193,7 +193,14 @@ int32_t world_init(int32_t seed, uint16_t chunk_size, uint16_t chunk_amount) { int32_t world_build_status = worldgen_test(&world); ZPL_ASSERT(world_build_status >= 0); - for (int i = 0; i < world.chunk_amount * world.chunk_amount; ++i) { + for (int i = 0; i < zpl_square(world.dim); ++i) { + if (world.data[i] == 0) { + ZPL_PANIC("Worldgen failure! Block %d is unset!\n", i); + return -1; + } + } + + for (int i = 0; i < zpl_square(world.chunk_amount); ++i) { ecs_entity_t e = ecs_new(world.ecs, 0); ecs_set(world.ecs, e, Classify, {.id = EKIND_CHUNK }); Chunk *chunk = ecs_get_mut(world.ecs, e, Chunk, NULL);