From 3b751d86e5250df530cb694c6bbe44829006c013 Mon Sep 17 00:00:00 2001 From: "Juan J. Martinez" Date: Sun, 16 Jul 2023 21:53:30 +0100 Subject: Extra life at 10,000 Also with special sound. --- src/game.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/game.c') diff --git a/src/game.c b/src/game.c index 609299f..c18b9ad 100644 --- a/src/game.c +++ b/src/game.c @@ -21,6 +21,8 @@ #define GAME_TIME_MAX 60 #define GAME_MAX_PICKAXE 3 +#define GAME_EXTRA_LIFE ((uint16_t)10000) + #define HUD_CLEAN 0 #define HUD_LIVES 1 #define HUD_SCORE 2 @@ -40,6 +42,7 @@ static volatile uint8_t clock_updated; /* game variables */ static uint8_t lives; static uint32_t score; +static uint16_t extra_life; static uint8_t stage; static uint8_t time; static uint8_t pickaxe; @@ -231,6 +234,7 @@ void run_game() { lives = GAME_LIVES_START; score = 0; + extra_life = 0; stage = START_STAGE; run_intro(); @@ -380,6 +384,19 @@ next_stage: void add_score(uint8_t v) { score += v; + extra_life += v; + + if (extra_life >= GAME_EXTRA_LIFE) + { + extra_life -= GAME_EXTRA_LIFE; + if (lives < 9) + { + sound_play_efx(EFX_ONEUP); + lives++; + hud |= HUD_LIVES; + } + } + hud |= HUD_SCORE; } -- cgit v1.2.3