summaryrefslogtreecommitdiff
path: root/src/game.c
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2022-12-12 17:41:58 -0800
committerVito Caputo <vcaputo@pengaru.com>2022-12-12 20:01:03 -0800
commite3085a3505bb30cf975804c519a3352bdc74d0dd (patch)
tree17134e1d50d78db9fb67aa6f810e99f2cd88cfe6 /src/game.c
parent095a0591af5dc026b9d48e282e5859eda84c646c (diff)
game: maintain an infections rate to drive plasma
Preparatory commit for tying plasma behavior to infections rate
Diffstat (limited to 'src/game.c')
-rw-r--r--src/game.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/game.c b/src/game.c
index 9cd3d4e..384728d 100644
--- a/src/game.c
+++ b/src/game.c
@@ -228,6 +228,7 @@ typedef struct game_t {
mask_t *mask;
teepee_t *teepee;
entity_t *new_infections;
+ float infections_rate, infections_rate_smoothed; /* 0-1 for none-max */
virus_t *viruses[GAME_NUM_VIRUSES];
m4f_t score_digits_x[10];
} game_t;
@@ -774,6 +775,8 @@ static void update_entities(play_t *play, game_t *game)
assert(play);
assert(game);
+ game->infections_rate_smoothed = (game->infections_rate + game->infections_rate_smoothed * 10.f) * (1.f / 11.f);
+
if (randf() > (1.f - GAME_TV_CHANCE) && !stage_get_active(game->tv->entity.node)) {
/* sometimes turn on the TV at a random location, we
* get stuck to it */
@@ -1278,11 +1281,15 @@ static void game_update(play_t *play, void *context)
}
if (play_ticks_elapsed(play, GAME_NEWBABIES_TIMER, GAME_NEWBABIES_DELAY_MS)) {
+ unsigned n_infections = 0;
+
for (unsigned n = GAME_NUM_BABIES - game->babies_cnt; n > 0; n--) {
baby_search_t search = { .game = game, .baby = game->rescues_head };
if (search.baby)
game->rescues_head = search.baby->rescues_next;
+ else
+ n_infections++;
search.baby = baby_new(game, game->babies_node, search.baby);
@@ -1292,6 +1299,8 @@ static void game_update(play_t *play, void *context)
else
game->babies_cnt++;
}
+
+ game->infections_rate = (1.f / GAME_NUM_BABIES) * (float)n_infections;
}
break;
© All Rights Reserved