diff --git a/sounds/quests/fall.ogg b/sounds/quests/fall.ogg index e8b47ac..d2403d0 100644 --- a/sounds/quests/fall.ogg +++ b/sounds/quests/fall.ogg @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e50fde2107befe2adeb9b2a0a46b68409b164655a927d5f20dffd83141cdd2ee -size 23430 +oid sha256:ab1254519cab9c504ea6e28f97b89387f84645928baebe7b0ada308a7d114c05 +size 25422 diff --git a/sounds/quests/safe_to_jump.ogg b/sounds/quests/safe_to_jump.ogg new file mode 100644 index 0000000..599366f --- /dev/null +++ b/sounds/quests/safe_to_jump.ogg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:def5bf9fe3c4a1e59e311d3c506eec2e3cd65fe58927b59364b616e0af6755c7 +size 4029 diff --git a/src/quests/escape_from_hel_game.nvgt b/src/quests/escape_from_hel_game.nvgt index 3d1a9e9..b832c2a 100644 --- a/src/quests/escape_from_hel_game.nvgt +++ b/src/quests/escape_from_hel_game.nvgt @@ -25,15 +25,17 @@ int run_escape_from_hel() { int total_steps = 0; int base_step_time = 900; string step_sound = "sounds/quests/footstep.ogg"; + const float listener_x = 0.0; + const float listener_y = 0.0; + const float pit_volume_step = 5.0; // Pit audio configuration int pit_fade_start = 6; // Start pit sound 6 steps before the pit - float start_volume = -35.0; // Start very quiet - float max_volume = 0.0; // Full volume at pit int pit_handle = -1; // Jump state bool jumping = false; + bool safe_jump_prompted = false; timer jump_timer; const int JUMP_DURATION = 400; // How long a jump lasts @@ -53,7 +55,7 @@ int run_escape_from_hel() { // Play footstep at start of step if (!jumping) { - p.play_stationary(step_sound, false); + p.play_2d(step_sound, listener_x, listener_y, listener_x, listener_y, false); } // Wait for step duration, checking for jump input @@ -62,7 +64,7 @@ int run_escape_from_hel() { // Allow jump anytime when not already jumping if (!jumping && key_pressed(KEY_SPACE)) { - p.play_stationary("sounds/quests/jump.ogg", false); + p.play_2d("sounds/quests/jump.ogg", listener_x, listener_y, listener_x, listener_y, false); jumping = true; jump_timer.restart(); } @@ -71,6 +73,13 @@ int run_escape_from_hel() { if (jumping && jump_timer.elapsed >= JUMP_DURATION) { jumping = false; } + + int steps_remaining = steps_until_pit - steps_taken; + int time_remaining = step_time - step_timer.elapsed; + if (!jumping && !safe_jump_prompted && steps_remaining == 1 && time_remaining <= JUMP_DURATION) { + p.play_2d("sounds/quests/safe_to_jump.ogg", listener_x, listener_y, listener_x, listener_y, false); + safe_jump_prompted = true; + } } steps_taken++; @@ -81,18 +90,15 @@ int run_escape_from_hel() { // Start pit sound when approaching if (steps_remaining <= pit_fade_start && steps_remaining >= 0 && pit_handle == -1) { - pit_handle = p.play_stationary("sounds/quests/pit.ogg", true); + pit_handle = p.play_2d("sounds/quests/pit.ogg", listener_x, listener_y, 0.0, steps_remaining, true); if (pit_handle != -1) { - p.update_sound_start_values(pit_handle, 0.0, start_volume, 1.0); + p.update_sound_positioning_values(pit_handle, -1.0, pit_volume_step); } } - // Update pit volume as we get closer + // Update pit position as we get closer if (pit_handle != -1 && steps_remaining >= 0) { - float progress = float(pit_fade_start - steps_remaining) / float(pit_fade_start); - if (progress > 1.0) progress = 1.0; - float current_volume = start_volume + (progress * (max_volume - start_volume)); - p.update_sound_start_values(pit_handle, 0.0, current_volume, 1.0); + p.update_sound_2d(pit_handle, 0.0, steps_remaining); } // Reached the pit @@ -104,7 +110,7 @@ int run_escape_from_hel() { p.destroy_sound(pit_handle); pit_handle = -1; } - p.play_stationary("sounds/quests/fall.ogg", false); + p.play_2d("sounds/quests/fall.ogg", listener_x, listener_y, listener_x, listener_y, false); speak_with_history("You fell in. Score " + score + ".", true); return score; } @@ -120,6 +126,7 @@ int run_escape_from_hel() { // Reset for next pit - random spacing between 5-15 steps steps_taken = 0; steps_until_pit = random(5, 15); + safe_jump_prompted = false; } } return score;