aboutsummaryrefslogtreecommitdiff
path: root/src/game.c
diff options
context:
space:
mode:
authorJuan J. Martinez <jjm@usebox.net>2023-07-29 12:57:54 +0100
committerJuan J. Martinez <jjm@usebox.net>2023-07-31 22:00:53 +0100
commit3c1a224d37eae97de7d1562ab280343352f925fe (patch)
tree55aebfea07e5e65be5ed65c9b648fa385e45172e /src/game.c
parent14f75c67f2e28428bbce5fe605a7bea7511cfa1e (diff)
downloadgold-mine-run-3c1a224d37eae97de7d1562ab280343352f925fe.tar.gz
gold-mine-run-3c1a224d37eae97de7d1562ab280343352f925fe.zip
Music WIP
Diffstat (limited to 'src/game.c')
-rw-r--r--src/game.c42
1 files changed, 35 insertions, 7 deletions
diff --git a/src/game.c b/src/game.c
index eed6749..d440cb8 100644
--- a/src/game.c
+++ b/src/game.c
@@ -32,7 +32,7 @@
#define HUD_ALL 255
#define GAMEOVER_DELAY 96
-#define STAGECLEAR_DELAY 96
+#define STAGECLEAR_DELAY 64
static uint32_t hiscore = 15000;
@@ -159,6 +159,10 @@ static void run_intro()
wait_frames(32);
+ sound_music_pattern(PAT_INTRO);
+ /* so the music starts */
+ wait_vsync();
+
blit_target(TARGET_SCREEN);
while (dst.x < 224)
{
@@ -181,6 +185,8 @@ static void run_intro()
wait_vsync();
blit_copy16(&dst);
+ wait_frames(32);
+ sound_music_pattern(PAT_SILENCE);
wait_frames(64);
}
@@ -196,18 +202,24 @@ static uint8_t run_gameover()
put_text(124, 90, "GAME OVER", 1);
+ sound_music_pattern(PAT_GAMEOVER);
+
/* wait some time, and check if the player wants to continue */
- for (uint16_t i = 0; i < 364; i++)
+ for (uint16_t i = 0; i < 524; i++)
{
- if (i == 64 || i == 300)
- put_text(68, 105, "PRESS SPACE TO CONTINUE", i == 64 ? 5 : 0);
+ if (i == 200 || i == 400)
+ put_text(68, 105, "PRESS SPACE TO CONTINUE", i == 200 ? 5 : 0);
- if (i > 64 && i < 300 && keys[KEY_SPACE])
+ if (i > 200 && i < 400 && keys[KEY_SPACE])
+ {
+ sound_music_pattern(PAT_SILENCE);
return 1;
+ }
wait_vsync();
}
+ sound_music_pattern(PAT_SILENCE);
return 0;
}
@@ -217,8 +229,10 @@ static void run_stageclear()
put_text(116, 100, "STAGE", 1);
put_text(164, 100, "CLEAR", 1);
+ sound_music_pattern(PAT_STAGE);
+
/* wait some time */
- wait_frames(96);
+ wait_frames(164);
while (time)
{
@@ -292,8 +306,10 @@ next_stage:
entities_draw();
put_text(136, 100, "READY?", 1);
+ sound_music_pattern(PAT_READY);
+
/* wait some time */
- wait_frames(96);
+ wait_frames(128);
/* erase the READY? text */
Rect ready = { 136, 100, 184, 8 };
@@ -303,6 +319,8 @@ next_stage:
timer_start(GAME_TIME_MAX, &clock_updated);
+ sound_music_pattern(PAT_PLAY);
+
while (!keys[KEY_ESC])
{
if (clock_updated)
@@ -346,9 +364,14 @@ next_stage:
}
else
{
+ if (stageclear == STAGECLEAR_DELAY)
+ sound_music_pattern(PAT_SILENCE);
+
stageclear--;
if (stageclear == 1)
{
+ sound_music_pattern(PAT_SILENCE);
+
run_stageclear();
stage++;
if (stage == STAGES_LEN)
@@ -391,6 +414,9 @@ next_stage:
if (gameover)
{
+ if (gameover == GAMEOVER_DELAY)
+ sound_music_pattern(PAT_SILENCE);
+
gameover--;
if (gameover == 1)
{
@@ -404,6 +430,8 @@ next_stage:
}
}
+ sound_music_pattern(PAT_SILENCE);
+
/* wait for ESC to be release */
while (keys[KEY_ESC])
wait_vsync();