Updated escape from hel quest.
This commit is contained in:
BIN
sounds/quests/fall.ogg
LFS
BIN
sounds/quests/fall.ogg
LFS
Binary file not shown.
BIN
sounds/quests/safe_to_jump.ogg
LFS
Normal file
BIN
sounds/quests/safe_to_jump.ogg
LFS
Normal file
Binary file not shown.
@@ -25,15 +25,17 @@ int run_escape_from_hel() {
|
|||||||
int total_steps = 0;
|
int total_steps = 0;
|
||||||
int base_step_time = 900;
|
int base_step_time = 900;
|
||||||
string step_sound = "sounds/quests/footstep.ogg";
|
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
|
// Pit audio configuration
|
||||||
int pit_fade_start = 6; // Start pit sound 6 steps before the pit
|
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;
|
int pit_handle = -1;
|
||||||
|
|
||||||
// Jump state
|
// Jump state
|
||||||
bool jumping = false;
|
bool jumping = false;
|
||||||
|
bool safe_jump_prompted = false;
|
||||||
timer jump_timer;
|
timer jump_timer;
|
||||||
const int JUMP_DURATION = 400; // How long a jump lasts
|
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
|
// Play footstep at start of step
|
||||||
if (!jumping) {
|
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
|
// Wait for step duration, checking for jump input
|
||||||
@@ -62,7 +64,7 @@ int run_escape_from_hel() {
|
|||||||
|
|
||||||
// Allow jump anytime when not already jumping
|
// Allow jump anytime when not already jumping
|
||||||
if (!jumping && key_pressed(KEY_SPACE)) {
|
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;
|
jumping = true;
|
||||||
jump_timer.restart();
|
jump_timer.restart();
|
||||||
}
|
}
|
||||||
@@ -71,6 +73,13 @@ int run_escape_from_hel() {
|
|||||||
if (jumping && jump_timer.elapsed >= JUMP_DURATION) {
|
if (jumping && jump_timer.elapsed >= JUMP_DURATION) {
|
||||||
jumping = false;
|
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++;
|
steps_taken++;
|
||||||
@@ -81,18 +90,15 @@ int run_escape_from_hel() {
|
|||||||
|
|
||||||
// Start pit sound when approaching
|
// Start pit sound when approaching
|
||||||
if (steps_remaining <= pit_fade_start && steps_remaining >= 0 && pit_handle == -1) {
|
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) {
|
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) {
|
if (pit_handle != -1 && steps_remaining >= 0) {
|
||||||
float progress = float(pit_fade_start - steps_remaining) / float(pit_fade_start);
|
p.update_sound_2d(pit_handle, 0.0, steps_remaining);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reached the pit
|
// Reached the pit
|
||||||
@@ -104,7 +110,7 @@ int run_escape_from_hel() {
|
|||||||
p.destroy_sound(pit_handle);
|
p.destroy_sound(pit_handle);
|
||||||
pit_handle = -1;
|
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);
|
speak_with_history("You fell in. Score " + score + ".", true);
|
||||||
return score;
|
return score;
|
||||||
}
|
}
|
||||||
@@ -120,6 +126,7 @@ int run_escape_from_hel() {
|
|||||||
// Reset for next pit - random spacing between 5-15 steps
|
// Reset for next pit - random spacing between 5-15 steps
|
||||||
steps_taken = 0;
|
steps_taken = 0;
|
||||||
steps_until_pit = random(5, 15);
|
steps_until_pit = random(5, 15);
|
||||||
|
safe_jump_prompted = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return score;
|
return score;
|
||||||
|
|||||||
Reference in New Issue
Block a user