aboutsummaryrefslogtreecommitdiff
path: root/src/game.c
diff options
context:
space:
mode:
authorJuan J. Martinez <jjm@usebox.net>2023-06-29 21:47:55 +0100
committerJuan J. Martinez <jjm@usebox.net>2023-06-29 21:47:55 +0100
commit2d2379251e71b5f315235db7980d0cfe03132561 (patch)
tree346ddd8719753fa1470cb8dc7456328d033ebff1 /src/game.c
parent16fb9f0d5e5904cca7c256b63f20f1fc1466bd5e (diff)
downloadgold-mine-run-2d2379251e71b5f315235db7980d0cfe03132561.tar.gz
gold-mine-run-2d2379251e71b5f315235db7980d0cfe03132561.zip
Add pickaxe pickup
Diffstat (limited to 'src/game.c')
-rw-r--r--src/game.c37
1 files changed, 35 insertions, 2 deletions
diff --git a/src/game.c b/src/game.c
index 70b1e74..64a7b23 100644
--- a/src/game.c
+++ b/src/game.c
@@ -16,12 +16,14 @@
#define GAME_LIVES_START 3
#define GAME_LIVES_MAX 9
#define GAME_TIME_MAX 60
+#define GAME_MAX_PICKAXE 3
#define HUD_CLEAN 0
#define HUD_LIVES 1
#define HUD_SCORE 2
#define HUD_STAGE 4
#define HUD_TIME 8
+#define HUD_PICKAXE 16
#define HUD_ALL 255
#define GAMEOVER_DELAY 96
@@ -35,8 +37,8 @@ static volatile uint8_t clock_updated;
static uint8_t lives;
static uint32_t score;
static uint8_t stage;
-static uint8_t gold;
static uint8_t time;
+static uint8_t pickaxe;
static uint8_t gameover;
static void hud_render()
@@ -51,6 +53,11 @@ static void hud_render()
/* lives */
blitrc(binary_sprites_start, &src, &dst);
+ /* pickaxe */
+ src.x = 112;
+ dst.x = 90;
+ blitrc(binary_sprites_start, &src, &dst);
+
put_text(132, 4, "TIME", 1);
put_text(249, 4, "STAGE", 1);
}
@@ -67,6 +74,12 @@ static void hud_render()
put_text(34, 4, b, 5);
}
+ if (hud & HUD_PICKAXE)
+ {
+ sprintf(b, "%d", pickaxe);
+ put_text(106, 4, b, 1);
+ }
+
if (hud & HUD_TIME)
{
sprintf(b, "%02d", time);
@@ -105,7 +118,7 @@ void run_game()
lives = GAME_LIVES_START;
score = 0;
stage = 0;
- gold = 30;
+ pickaxe = 0;
time = GAME_TIME_MAX;
hud = HUD_ALL;
@@ -191,3 +204,23 @@ void reset_time()
hud |= HUD_TIME;
timer_start(GAME_TIME_MAX, &clock_updated);
}
+
+void add_pickaxe()
+{
+ if (pickaxe < GAME_MAX_PICKAXE)
+ {
+ pickaxe++;
+ hud |= HUD_PICKAXE;
+ }
+}
+
+uint8_t use_pickaxe()
+{
+ if (pickaxe)
+ {
+ pickaxe--;
+ hud |= HUD_PICKAXE;
+ return 1;
+ }
+ return 0;
+}