Techneck/code/source-c/default_terrain_generator.c

52 lines
1.5 KiB
C
Raw Normal View History

2023-10-11 08:10:06 +00:00
#include "world.h"
bool tc_generate_default_terrain_chunk(tc_worldgen_s *gen, tc_chunk_s *chunk)
{
tc_block_s block;
2023-10-13 10:23:26 +00:00
block.type_identifier = 1 | TC_BLOCK_OPAQUE_BIT;
2023-10-11 08:10:06 +00:00
block.position.x = 0.0f;
block.position.y = 0.0f;
block.position.z = 0.0f;
tc_block_s grass;
grass.type_identifier = 2 | TC_BLOCK_OPAQUE_BIT;
2023-10-13 06:00:53 +00:00
if(chunk->position.y > 0) return true;
2023-10-11 08:10:06 +00:00
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;
}
if(chunk->position.y == 0)
{
x_in_chunk = 0;
while(x_in_chunk < 32)
{
z_in_chunk = 0;
while(z_in_chunk < 32)
{
tc_set_block_in_chunk(chunk, x_in_chunk, 31, z_in_chunk, grass);
++z_in_chunk;
}
++x_in_chunk;
}
}
2023-10-11 08:10:06 +00:00
return true;
2023-10-12 06:18:43 +00:00
}