summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2022-10-17 20:13:37 -0700
committerVito Caputo <vcaputo@pengaru.com>2022-10-17 20:13:37 -0700
commit60d28d1309cf37942363d10f7d135b02a4c82078 (patch)
tree9d208cb73fdf7b8d513dd490ade922311126981d
parentbeb8db245d07d349cd339ff87cfadc1a4ad27179 (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.
-rw-r--r--src/game.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/game.c b/src/game.c
index f304094..0d3f57e 100644
--- a/src/game.c
+++ b/src/game.c
@@ -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);
}
}
}
© All Rights Reserved