pre-work for chunk stitching

isolation_bkp/dynres
Dominik Madarász 2021-05-14 07:02:25 +02:00
parent ffbb2c1333
commit 903bcc3afa
5 changed files with 10 additions and 4 deletions

View File

@ -5,7 +5,7 @@ Image texgen_build_block(uint32_t biome, uint32_t kind) {
// TODO(zaklaus):
(void)biome;
(void)kind;
return GenImageColor(WORLD_BLOCK_SIZE, WORLD_BLOCK_SIZE, RAYWHITE);
return GenImageWhiteNoise(WORLD_BLOCK_SIZE, WORLD_BLOCK_SIZE, 0.8f);
}
Texture2D texgen_build_sprite(asset_id id) {

View File

@ -27,7 +27,6 @@ uint64_t player_spawn(char *name) {
ecs_set(world_ecs(), e, Input, {0});
ecs_add(world_ecs(), e, Player);
Position *pos = ecs_get_mut(world_ecs(), e, Position, NULL);
uint16_t half_world_dim = world_dim() / 2;
pos->x=rand() % world_dim();
pos->y=rand() % world_dim();

View File

@ -144,6 +144,13 @@ int32_t world_init(int32_t seed, uint16_t chunk_size, uint16_t chunk_amount) {
librg_entity_track(world.tracker, e);
librg_entity_chunk_set(world.tracker, e, i);
librg_chunk_to_chunkpos(world.tracker, i, &chunk->x, &chunk->y, NULL);
chunk->blocks = NULL;
// TODO(zaklaus): populate chunks from worldgen
for (int j = 0; j < world.chunk_size * world.chunk_size; j += 1) {
uint8_t *c = ecs_vector_add(&chunk->blocks, uint8_t);
*c = 0;
}
}
zpl_printf("[INFO] Created a new server world\n");

View File

@ -6,7 +6,7 @@
ECS_STRUCT(Vector2D, {
float x;
float y;
});
});
ECS_STRUCT(Chunk, {
int16_t x;

View File

@ -18,7 +18,7 @@ void MoveWalk(ecs_iter_t *it) {
void HandleCollisions(ecs_iter_t *it) {
Position *p = ecs_column(it, Position, 1);
Velocity *v = ecs_column(it, Velocity, 2);
//Velocity *v = ecs_column(it, Velocity, 2);
for (int i = 0; i < it->count; i++) {
// NOTE(zaklaus): world bounds