From 8b99e939c5fb2dd9ecfba0f9f12e4d2950845d11 Mon Sep 17 00:00:00 2001 From: "Juan J. Martinez" Date: Fri, 28 Jul 2023 12:02:01 +0100 Subject: Add "continue" support --- src/game.c | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) (limited to 'src/game.c') 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; } } -- cgit v1.2.3