Try to get a good position to spawn at. Also gets a good initial move-direction based on where you spawn.

This commit is contained in:
2025-12-18 12:57:06 +01:00
parent 199afff820
commit c1f43fdc61
5 changed files with 99 additions and 11 deletions

View File

@@ -62,18 +62,27 @@ void simulation_world_tick(Simulation_World *simulation_world) {
assert(!player->active);
player->active = true;
Game_World *gw = simulation_world->game_world;
assert(gw != NULL);
uint16_t spawn_x = 0;
uint16_t spawn_y = 0;
assert(game_world_find_position_to_spawn(gw, &spawn_x, &spawn_y));
assert(game_world_create_entity(
simulation_world->game_world,
gw,
Entity_Type_Snake_Head,
i+6, 15, // NOTE: SS - Hardcoded spawn-position.
spawn_x, spawn_y,
&player->entity_id
));
Entity *player_entity = game_world_try_get_entity_by_id(simulation_world->game_world, player->entity_id);
Entity *player_entity = game_world_try_get_entity_by_id(gw, player->entity_id);
// Set initial move-direction for player-entities.
// The initial direction should probably take the spawn-position in to account.
player_entity->move_direction = Entity_Movement_Direction_Up;
player_entity->move_direction = game_world_choose_initial_move_direction_based_on_coords(
gw,
spawn_x, spawn_y
);
break;
}