diff options
author | Vito Caputo <vcaputo@pengaru.com> | 2022-10-17 20:13:37 -0700 |
---|---|---|
committer | Vito Caputo <vcaputo@pengaru.com> | 2022-10-17 20:13:37 -0700 |
commit | 60d28d1309cf37942363d10f7d135b02a4c82078 (patch) | |
tree | 9d208cb73fdf7b8d513dd490ade922311126981d /src | |
parent | beb8db245d07d349cd339ff87cfadc1a4ad27179 (diff) |
game: handle infecting multiple babies at once
It's possible for babies to overlap and a virus to encounter them
simultaneously. The existing code halted the search on the first
hit. This commit changes things to continue the search and
infect all hits before resetting the infecting virus.
Diffstat (limited to 'src')
-rw-r--r-- | src/game.c | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -323,11 +323,10 @@ static ix2_search_status_t virus_search(void *cb_context, ix2_object_t *ix2_obje sfx_play(sfx.baby_infected); entity->any.type = ENTITY_TYPE_VIRUS; - (void) baby_new(search->game, search->game->babies_node); - reset_virus(search->virus); + (void) baby_new(search->game, search->game->babies_node); - return IX2_SEARCH_STOP_HIT; + return IX2_SEARCH_MORE_HIT; case ENTITY_TYPE_ADULT: /* convert adult into inanimate virus (off the viruses array) */ @@ -398,7 +397,8 @@ static void update_entities(play_t *play, game_t *game) search.virus = virus; /* search ix2 for collisions */ - ix2_search_by_aabb(game->ix2, NULL, NULL, &virus->entity.aabb_x, virus_search, &search); + if (ix2_search_by_aabb(game->ix2, NULL, NULL, &virus->entity.aabb_x, virus_search, &search)) + reset_virus(virus); } } } |