diff options
author | Vito Caputo <vcaputo@pengaru.com> | 2022-12-02 21:23:41 -0800 |
---|---|---|
committer | Vito Caputo <vcaputo@pengaru.com> | 2022-12-02 21:39:54 -0800 |
commit | 8db8b8d3ac508da475a5dafb4b8adf0f231b3014 (patch) | |
tree | 1569d71a2539f89b456fcb16fc3685267eb06cde /src/game.c | |
parent | 4b802d905f813b65f32deac3b87d06c96486f123 (diff) |
game: move probabilities to named defines
Nothing functionally changed, just naming some magic numbers and
putting them somewhere more organized.
Diffstat (limited to 'src/game.c')
-rw-r--r-- | src/game.c | 11 |
1 files changed, 8 insertions, 3 deletions
@@ -85,6 +85,11 @@ #define GAME_VIRUS_SCALE (v3f_t){ .05f, .05f, .05f } #define GAME_DIGITS_SCALE (v3f_t){ .05f, .05f, .05f } +#define GAME_TV_CHANCE .05f +#define GAME_MASK_CHANCE .02f +#define GAME_TEEPEE_CHANCE .55f + + /* every entity just starts with a unit cube AABB and is transformed with a matrix into its position, * so here's a convenient aabb to feed into those transformations as needed. */ @@ -675,7 +680,7 @@ static void update_entities(play_t *play, game_t *game) assert(play); assert(game); - if (randf() > .95f && !stage_get_active(game->tv->entity.node)) { + 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 */ play_ticks_reset(play, GAME_TV_TIMER); @@ -685,7 +690,7 @@ static void update_entities(play_t *play, game_t *game) stage_set_active(game->tv->entity.node, 1); } - if (randf() > .98f && !stage_get_active(game->mask->entity.node)) { + if (randf() > (1.f - GAME_MASK_CHANCE) && !stage_get_active(game->mask->entity.node)) { /* sometimes activate a mask powerup */ game->mask->entity.position.x = randf(); game->mask->entity.position.y = -1.2f; @@ -693,7 +698,7 @@ static void update_entities(play_t *play, game_t *game) stage_set_active(game->mask->entity.node, 1); } - if (randf() > .45f && !stage_get_active(game->teepee->entity.node)) { + if (randf() > (1.f - GAME_TEEPEE_CHANCE) && !stage_get_active(game->teepee->entity.node)) { /* sometimes activate a teepee "powerup" */ static struct { unsigned qty; |