aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJuan J. Martinez <jjm@usebox.net>2023-07-04 23:20:45 +0100
committerJuan J. Martinez <jjm@usebox.net>2023-07-04 23:20:45 +0100
commit5efea24f028e595433caa8707c3b25c98d1aedbf (patch)
treeeb56c79bbfb74208b715bdfcb8cb57748f789941 /src
parent49379fe29f1e4a1ed19ada85db4c37909a611142 (diff)
downloadgold-mine-run-5efea24f028e595433caa8707c3b25c98d1aedbf.tar.gz
gold-mine-run-5efea24f028e595433caa8707c3b25c98d1aedbf.zip
Stage complete sequence
Diffstat (limited to 'src')
-rw-r--r--src/game.c107
1 files changed, 82 insertions, 25 deletions
diff --git a/src/game.c b/src/game.c
index 9d126d1..101a053 100644
--- a/src/game.c
+++ b/src/game.c
@@ -29,6 +29,7 @@
#define HUD_ALL 255
#define GAMEOVER_DELAY 96
+#define STAGECLEAR_DELAY 96
static uint32_t hiscore = 15000;
@@ -41,6 +42,7 @@ static uint32_t score;
static uint8_t stage;
static uint8_t time;
static uint8_t pickaxe;
+static uint8_t stageclear;
static uint8_t gameover;
static uint8_t pause;
static Entity *tmonster;
@@ -87,8 +89,8 @@ static void hud_render()
if (hud & HUD_TIME)
{
sprintf(b, "%02d", time);
- put_text(172, 4, b, time > 10 ? 1 : 15);
- if (!gameover && time <= 10)
+ put_text(172, 4, b, time > 10 || stageclear ? 1 : 15);
+ if (!gameover && !stageclear && time <= 10)
sound_queue_efx(EFX_TIME);
}
@@ -118,20 +120,58 @@ static void run_gameover()
wait_frames(255);
}
-void run_game()
+static void run_stageclear()
{
- pause = 0;
- gameover = 0;
+ put_text(116, 100, "STAGE CLEAR", 1);
+
+ wait_vsync();
+ blit_update();
+
+ /* wait some time */
+ wait_frames(96);
+
+ while (time--)
+ {
+ add_score(25);
+ hud |= HUD_TIME;
+ sound_queue_efx(EFX_GOLD);
+ hud_render();
+
+ wait_frames(4);
+ blit_update();
+ sound_play_queue();
+ }
+
+ /* wait some time */
+ wait_frames(64);
+
+ blit_erase(0);
+ /* restore the HUD after erasing the screen */
+ hud = HUD_ALL;
+ hud_render();
+ wait_vsync();
+ blit_update();
+ wait_frames(32);
+}
+
+void run_game()
+{
lives = GAME_LIVES_START;
score = 0;
stage = 0;
+
+next_stage:
+ pause = 0;
+ gameover = 0;
+ stageclear = 0;
+
pickaxe = 0;
time = GAME_TIME_MAX;
- tmonster = NULL;
-
hud = HUD_ALL;
+ tmonster = NULL;
+
blit_erase(0);
map_init(binary_stage_start);
@@ -189,34 +229,51 @@ void run_game()
player_erase();
entities_erase();
- player_update();
- entities_update();
-
- /* time monster */
- if (!time && !tmonster)
+ if (map_is_complete())
{
- tmonster = entities_new();
- if (tmonster)
- tmonster_init(tmonster);
+ if (!stageclear)
+ {
+ timer_stop();
+ tmonster = NULL;
+ entities_warp_out_all();
+ sound_queue_efx(EFX_WARP);
+
+ stageclear = STAGECLEAR_DELAY;
+ }
+ else
+ {
+ stageclear--;
+ if (stageclear == 1)
+ {
+ run_stageclear();
+ goto next_stage;
+ }
+ }
}
- if (time && tmonster)
+ else
{
- tmonster->used = 0;
- tmonster = NULL;
- }
+ player_update();
- if (map_is_complete())
- {
- tmonster = NULL;
- timer_stop();
- entities_warp_out_all();
+ /* time monster */
+ if (!time && !tmonster)
+ {
+ tmonster = entities_new();
+ if (tmonster)
+ tmonster_init(tmonster);
+ }
+ if (time && tmonster)
+ {
+ tmonster->used = 0;
+ tmonster = NULL;
+ }
}
+ entities_update();
+
entities_draw();
player_draw();
wait_vsync();
-
blit_update();
sound_play_queue();