aboutsummaryrefslogtreecommitdiff
path: root/src/game.c
diff options
context:
space:
mode:
authorJuan J. Martinez <jjm@usebox.net>2023-06-15 22:58:30 +0100
committerJuan J. Martinez <jjm@usebox.net>2023-06-15 22:58:30 +0100
commita1de326ac5d89cbf9555c9a0a9a662af35c6dcf7 (patch)
treeffe56e86be4acefcee8b89753cf31f7a8c1db20d /src/game.c
parent07e829e591394fa182e75ecab86051f1fb850ce7 (diff)
downloadgold-mine-run-a1de326ac5d89cbf9555c9a0a9a662af35c6dcf7.tar.gz
gold-mine-run-a1de326ac5d89cbf9555c9a0a9a662af35c6dcf7.zip
Implement a countdown clock in the timer
Updated the HUD to show the time.
Diffstat (limited to 'src/game.c')
-rw-r--r--src/game.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/game.c b/src/game.c
index 70c3235..b49e859 100644
--- a/src/game.c
+++ b/src/game.c
@@ -12,12 +12,14 @@
static uint32_t hiscore = 15000;
static uint8_t hud;
+static volatile uint8_t clock_updated;
/* game variables */
static uint8_t lives;
static uint32_t score;
static uint8_t stage;
static uint8_t gold;
+static uint8_t time;
void hud_render()
{
@@ -49,7 +51,7 @@ void hud_render()
if (hud & HUD_TIME)
{
- sprintf(b, "%02d", 0);
+ sprintf(b, "%02d", time);
put_text(172, 4, b);
}
@@ -68,14 +70,23 @@ void run_game()
score = 0;
stage = 0;
gold = 30;
+ time = GAME_TIME_MAX;
hud = HUD_ALL;
map_init(binary_stage_start);
map_render();
+ timer_start(GAME_TIME_MAX, &clock_updated);
+
while (!keys[KEY_ESC])
{
+ if (clock_updated)
+ {
+ time = timer_value();
+ hud |= HUD_TIME;
+ }
+
if (hud)
hud_render();