validate worldgen data
parent
3ce8df35dc
commit
5cf92444e2
|
@ -14,6 +14,13 @@ Texture2D LoadImageEco(const char *name) {
|
||||||
|
|
||||||
Texture2D texgen_build_sprite(asset_id id) {
|
Texture2D texgen_build_sprite(asset_id id) {
|
||||||
switch (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");
|
case ASSET_DEMO_ICEMAKER: return LoadImageEco("demo_icemaker");
|
||||||
|
|
||||||
// NOTE(zaklaus): blocks
|
// NOTE(zaklaus): blocks
|
||||||
|
@ -41,6 +48,4 @@ Texture2D texgen_build_sprite(asset_id id) {
|
||||||
return tex;
|
return tex;
|
||||||
}break;
|
}break;
|
||||||
}
|
}
|
||||||
|
|
||||||
ZPL_PANIC("unreachable code");
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
static block blocks[] = {
|
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_GROUND, 0, '.', .drag = 1.0f, .friction = 1.0f),
|
||||||
BLOCK(ASSET_DIRT, 0, ',', .drag = 2.1f , .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),
|
BLOCK(ASSET_WALL, BLOCK_FLAG_COLLISION, '#', .drag = 1.0f , .friction = 1.0f, .bounce = 1.0f),
|
||||||
|
|
|
@ -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);
|
int32_t world_build_status = worldgen_test(&world);
|
||||||
ZPL_ASSERT(world_build_status >= 0);
|
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_entity_t e = ecs_new(world.ecs, 0);
|
||||||
ecs_set(world.ecs, e, Classify, {.id = EKIND_CHUNK });
|
ecs_set(world.ecs, e, Classify, {.id = EKIND_CHUNK });
|
||||||
Chunk *chunk = ecs_get_mut(world.ecs, e, Chunk, NULL);
|
Chunk *chunk = ecs_get_mut(world.ecs, e, Chunk, NULL);
|
||||||
|
|
Loading…
Reference in New Issue