aboutsummaryrefslogtreecommitdiff
path: root/src/game.c
diff options
context:
space:
mode:
authorJuan J. Martinez <jjm@usebox.net>2023-07-13 22:44:40 +0100
committerJuan J. Martinez <jjm@usebox.net>2023-07-13 22:44:40 +0100
commitf88ab2affc7b1a4c91278444c80977b83b2556cb (patch)
tree78321c92a38692c84c3a20d8102c222ddffc56d3 /src/game.c
parentb33c3e948b72f71176cd57afd2085835bab64ff7 (diff)
downloadgold-mine-run-f88ab2affc7b1a4c91278444c80977b83b2556cb.tar.gz
gold-mine-run-f88ab2affc7b1a4c91278444c80977b83b2556cb.zip
Add intro screen
Diffstat (limited to 'src/game.c')
-rw-r--r--src/game.c63
1 files changed, 63 insertions, 0 deletions
diff --git a/src/game.c b/src/game.c
index 85fb050..7fe6d78 100644
--- a/src/game.c
+++ b/src/game.c
@@ -110,6 +110,67 @@ static void hud_render()
hud = HUD_CLEAN;
}
+#define WALK_DELAY 8
+#define WALK_CYCLE_FRAMES 4
+
+static const Rect intro_frames[WALK_CYCLE_FRAMES] =
+{
+ /* walk cycle */
+ { 0, 0, 144, 144 },
+ { 16, 0, 144, 144 },
+ { 0, 0, 144, 144 },
+ { 32, 0, 144, 144 },
+};
+
+static void run_intro()
+{
+ /* for the HUD */
+ pickaxe = 0;
+ time = GAME_TIME_MAX;
+ hud = HUD_ALL;
+
+ blit_target(TARGET_BUFFER);
+ blit_erase(0);
+
+ map_init(binary_intro_start);
+
+ map_render();
+ hud_render();
+ put_text(88, 65, "GET ALL THAT GOLD!", 1);
+
+ wait_vsync();
+ blit_copy_all();
+
+ Rect dst = { 80, 88 + MAP_OFFS_Y, 16, 16 };
+ uint8_t frame = 0, delay = 0;
+
+ wait_frames(32);
+
+ blit_target(TARGET_SCREEN);
+ while (dst.x < 224)
+ {
+ wait_vsync();
+ blit_copy16(&dst);
+ dst.x++;
+ if (map_update_gold(dst.x + 8, dst.y + 15 - MAP_OFFS_Y))
+ sound_play_efx(EFX_GOLD);
+ blitrc(binary_sprites_start, &intro_frames[frame], &dst);
+
+ if (delay++ == WALK_DELAY)
+ {
+ delay = 0;
+ frame++;
+ if (frame == WALK_CYCLE_FRAMES)
+ frame = 0;
+ }
+ }
+
+ wait_vsync();
+ blit_copy16(&dst);
+
+ wait_frames(64);
+}
+
static void run_gameover()
{
wait_vsync();
@@ -167,6 +228,8 @@ void run_game()
score = 0;
stage = 0;
+ run_intro();
+
next_stage:
pause = 0;
gameover = 0;