aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJuan J. Martinez <jjm@usebox.net>2023-07-16 21:53:30 +0100
committerJuan J. Martinez <jjm@usebox.net>2023-07-16 21:53:30 +0100
commit3b751d86e5250df530cb694c6bbe44829006c013 (patch)
tree2790f4dc41b816d3c7ec965693deff646d57af28 /src
parenta123a75eae0c48402f8a737fa94a63e2e47fbb31 (diff)
downloadgold-mine-run-3b751d86e5250df530cb694c6bbe44829006c013.tar.gz
gold-mine-run-3b751d86e5250df530cb694c6bbe44829006c013.zip
Extra life at 10,000
Also with special sound.
Diffstat (limited to 'src')
-rw-r--r--src/data.h2
-rw-r--r--src/game.c17
-rw-r--r--src/sound.c3
-rw-r--r--src/sound.h1
4 files changed, 22 insertions, 1 deletions
diff --git a/src/data.h b/src/data.h
index 0006a4a..255ec35 100644
--- a/src/data.h
+++ b/src/data.h
@@ -36,6 +36,7 @@ extern const uint8_t binary_time_efx_start[];
extern const uint8_t binary_gold_efx_start[];
extern const uint8_t binary_pickup_efx_start[];
extern const uint8_t binary_warp_efx_start[];
+extern const uint8_t binary_oneup_efx_start[];
extern const uint8_t binary_hit_efx_size;
extern const uint8_t binary_death_efx_size;
@@ -44,5 +45,6 @@ extern const uint8_t binary_time_efx_size;
extern const uint8_t binary_gold_efx_size;
extern const uint8_t binary_pickup_efx_size;
extern const uint8_t binary_warp_efx_size;
+extern const uint8_t binary_oneup_efx_size;
#endif /* _DATA_H */
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;
}
diff --git a/src/sound.c b/src/sound.c
index c9e3b1c..aeeeeb8 100644
--- a/src/sound.c
+++ b/src/sound.c
@@ -12,7 +12,7 @@ typedef struct
size_t len;
} Efx;
-#define EFX_CNT 7
+#define EFX_CNT 8
static Efx efx[EFX_CNT] =
{
@@ -21,6 +21,7 @@ static Efx efx[EFX_CNT] =
{ NULL, (const char *)binary_warp_efx_start, (size_t)&binary_warp_efx_size},
{ NULL, (const char *)binary_pickup_efx_start, (size_t)&binary_pickup_efx_size},
{ NULL, (const char *)binary_time_efx_start, (size_t)&binary_time_efx_size},
+ { NULL, (const char *)binary_oneup_efx_start, (size_t)&binary_oneup_efx_size},
{ NULL, (const char *)binary_hit_efx_start, (size_t)&binary_hit_efx_size},
{ NULL, (const char *)binary_death_efx_start, (size_t)&binary_death_efx_size},
};
diff --git a/src/sound.h b/src/sound.h
index d8b14ac..5f96d29 100644
--- a/src/sound.h
+++ b/src/sound.h
@@ -7,6 +7,7 @@ enum {
EFX_WARP,
EFX_PICKUP,
EFX_TIME,
+ EFX_ONEUP,
EFX_HIT,
EFX_DEATH,
};