From b3dd12d7b6260a8158ca9c84c6cfb8f8e799edaa Mon Sep 17 00:00:00 2001 From: "Juan J. Martinez" Date: Sat, 5 Aug 2023 15:32:57 +0100 Subject: End of game screen --- TODO.md | 5 ++-- data/tiles.png | Bin 13827 -> 15636 bytes src/game.c | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++++----- 3 files changed, 84 insertions(+), 11 deletions(-) diff --git a/TODO.md b/TODO.md index a6ba954..d9459d7 100644 --- a/TODO.md +++ b/TODO.md @@ -1,7 +1,6 @@ # TODO -- screens - - end game +Post-release: -# REVIEW +- external level pack support? diff --git a/data/tiles.png b/data/tiles.png index 2901874..1c8dfd1 100644 Binary files a/data/tiles.png and b/data/tiles.png differ diff --git a/src/game.c b/src/game.c index 35fc49c..2d41821 100644 --- a/src/game.c +++ b/src/game.c @@ -116,7 +116,7 @@ static void hud_render() if (hud & HUD_STAGE) { - sprintf(b, "%02d", stage + 1); + sprintf(b, "%02d", stage < STAGES_LEN ? stage + 1 : stage); put_text(297, 4, b, 1); } @@ -207,13 +207,16 @@ static uint8_t run_gameover() /* wait some time, and check if the player wants to continue */ for (uint16_t i = 0; i < 524; i++) { - if (i == 200 || i == 400) - put_text(68, 105, "PRESS SPACE TO CONTINUE", i == 200 ? 5 : 0); - - if (i > 200 && i < 400 && keys[KEY_SPACE]) + if (stage < STAGES_LEN) { - sound_music_pattern(PAT_SILENCE); - return 1; + if (i == 200 || i == 400) + put_text(68, 105, "PRESS SPACE TO CONTINUE", i == 200 ? 5 : 0); + + if (i > 200 && i < 400 && keys[KEY_SPACE]) + { + sound_music_pattern(PAT_SILENCE); + return 1; + } } wait_vsync(); @@ -223,6 +226,77 @@ static uint8_t run_gameover() return 0; } +static const Rect pop_in_frames[] = +{ + { 128, 16, 144, 112 }, + { 112, 16, 144, 112 } +}; + +static const Rect pop_in_letters[] = +{ + { 32, 32, 160, 48 }, + { 48, 32, 160, 48 }, + { 64, 32, 160, 48 }, + { 64, 32, 160, 48 }, + { 80, 32, 160, 48 }, + { 96, 32, 160, 48 }, + { 112, 32, 160, 48 }, + { 48, 32, 160, 48 }, +}; + +static void pop_in_letter(uint16_t x, uint16_t y, uint8_t letter) +{ + Rect dst = { x, y, 16, 16 }; + const Rect *src; + + sound_play_efx(EFX_WARP); + for (uint8_t i = 0; i < 2; i++) + { + src = &pop_in_frames[i]; + wait_vsync(); + blitrc(binary_sprites_start, src, &dst); + wait_frames(7); + } + + src = &pop_in_letters[letter]; + wait_vsync(); + blitrc(binary_tiles_start, src, &dst); +} + +static void run_endgame() +{ + blit_target(TARGET_BUFFER); + blit_erase(0); + + /* for the HUD */ + pickaxe = 0; + time = GAME_TIME_MAX; + hud = HUD_ALL; + + hud_render(); + wait_vsync(); + blit_copy_all(); + + blit_target(TARGET_SCREEN); + + for (uint8_t i = 0; i < 4; i++) + pop_in_letter(88 + i * 16, 60, i); + + for (uint8_t i = 0; i < 4; i++) + pop_in_letter(168 + i * 16, 60, 4 + i); + + wait_vsync(); + put_text(48, 100, "YOU HAVE COMPLETED THE GAME!", 1); + put_text(108, 115, "THANK YOU FOR", 6); + put_text(72, 125, "PLAYING GOLD MINE RUN!", 6); + + sound_music_pattern(PAT_STAGE); + + wait_frames(512); + + run_gameover(); +} + static void run_stageclear() { blit_target(TARGET_BUFFER); @@ -376,7 +450,7 @@ next_stage: stage++; if (stage == STAGES_LEN) { - /* TODO: endgame */ + run_endgame(); break; } goto next_stage; -- cgit v1.2.3