aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJuan J. Martinez <jjm@usebox.net>2023-07-28 12:02:01 +0100
committerJuan J. Martinez <jjm@usebox.net>2023-07-28 12:02:01 +0100
commit8b99e939c5fb2dd9ecfba0f9f12e4d2950845d11 (patch)
treeaed93d28691fd49371f9569bb06afef1b79b3948 /src
parent82f86d98bbea508b0d5b44acaa24691024bc12d3 (diff)
downloadgold-mine-run-8b99e939c5fb2dd9ecfba0f9f12e4d2950845d11.tar.gz
gold-mine-run-8b99e939c5fb2dd9ecfba0f9f12e4d2950845d11.zip
Add "continue" support
Diffstat (limited to 'src')
-rw-r--r--src/game.c34
1 files changed, 28 insertions, 6 deletions
diff --git a/src/game.c b/src/game.c
index 116aec1..eed6749 100644
--- a/src/game.c
+++ b/src/game.c
@@ -50,6 +50,7 @@ static uint8_t stageclear;
static uint8_t gameover;
static uint8_t pause;
static Entity *tmonster;
+static uint8_t continuegame;
/* 0-index */
#define START_STAGE 0
@@ -183,7 +184,7 @@ static void run_intro()
wait_frames(64);
}
-static void run_gameover()
+static uint8_t run_gameover()
{
wait_vsync();
@@ -195,8 +196,19 @@ static void run_gameover()
put_text(124, 90, "GAME OVER", 1);
- /* wait some time */
- wait_frames(255);
+ /* wait some time, and check if the player wants to continue */
+ for (uint16_t i = 0; i < 364; i++)
+ {
+ if (i == 64 || i == 300)
+ put_text(68, 105, "PRESS SPACE TO CONTINUE", i == 64 ? 5 : 0);
+
+ if (i > 64 && i < 300 && keys[KEY_SPACE])
+ return 1;
+
+ wait_vsync();
+ }
+
+ return 0;
}
static void run_stageclear()
@@ -237,12 +249,18 @@ static void run_stageclear()
void run_game()
{
+ continuegame = 0;
+
+continue_game:
lives = GAME_LIVES_START;
score = 0;
extra_life = 0;
- stage = START_STAGE;
- run_intro();
+ if (!continuegame)
+ {
+ stage = START_STAGE;
+ run_intro();
+ }
next_stage:
pause = 0;
@@ -376,7 +394,11 @@ next_stage:
gameover--;
if (gameover == 1)
{
- run_gameover();
+ if (run_gameover())
+ {
+ continuegame = 1;
+ goto continue_game;
+ }
break;
}
}