Techneck/code/source-c/default_terrain_generator.c

38 lines
1.1 KiB
C

#include "world.h"
bool tc_generate_default_terrain_chunk(tc_worldgen_s *gen, tc_chunk_s *chunk)
{
tc_block_s block;
block.type_identifier = 1 | TC_BLOCK_OPAQUE_BIT;
block.position.x = 0.0f;
block.position.y = 0.0f;
block.position.z = 0.0f;
if(chunk->position.y > 0) return true;
uint32_t x_in_chunk = 0;
uint32_t y_in_chunk = 0;
uint32_t z_in_chunk = 0;
while(x_in_chunk < 32)
{
y_in_chunk = 0;
while(y_in_chunk < 32)
{
z_in_chunk = 0;
while(z_in_chunk < 32)
{
tc_set_block_in_chunk(chunk, x_in_chunk, y_in_chunk, z_in_chunk, block);
++z_in_chunk;
}
++y_in_chunk;
}
++x_in_chunk;
}
tc_block_s air;
block.type_identifier = 0;
tc_set_block_in_chunk(chunk, 6, 8, 14, air);
return true;
}