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:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user