diff options
author | Juan J. Martinez <jjm@usebox.net> | 2023-07-16 21:53:30 +0100 |
---|---|---|
committer | Juan J. Martinez <jjm@usebox.net> | 2023-07-16 21:53:30 +0100 |
commit | 3b751d86e5250df530cb694c6bbe44829006c013 (patch) | |
tree | 2790f4dc41b816d3c7ec965693deff646d57af28 /src/game.c | |
parent | a123a75eae0c48402f8a737fa94a63e2e47fbb31 (diff) | |
download | gold-mine-run-3b751d86e5250df530cb694c6bbe44829006c013.tar.gz gold-mine-run-3b751d86e5250df530cb694c6bbe44829006c013.zip |
Extra life at 10,000
Also with special sound.
Diffstat (limited to 'src/game.c')
-rw-r--r-- | src/game.c | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -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; } |