diff options
author | Juan J. Martinez <jjm@usebox.net> | 2023-08-05 15:32:57 +0100 |
---|---|---|
committer | Juan J. Martinez <jjm@usebox.net> | 2023-08-05 15:32:57 +0100 |
commit | b3dd12d7b6260a8158ca9c84c6cfb8f8e799edaa (patch) | |
tree | 06fc2d46b0fc53fd3eef80a9b01cb01b531d09f8 /src | |
parent | ebb1f0f38cd3adc1ff8633d3b810dfea33d1a9cb (diff) | |
download | gold-mine-run-b3dd12d7b6260a8158ca9c84c6cfb8f8e799edaa.tar.gz gold-mine-run-b3dd12d7b6260a8158ca9c84c6cfb8f8e799edaa.zip |
End of game screen
Diffstat (limited to 'src')
-rw-r--r-- | src/game.c | 90 |
1 files changed, 82 insertions, 8 deletions
@@ -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; |