Sound has been updated. As a result snares can be collected from a bit further away as it is now harder to tell when you're about to step on it. A few string updates. Mountain terrain added. May require rope for traversal.

This commit is contained in:
Storm Dragon
2026-01-19 15:00:01 -05:00
parent 93dfd7347b
commit 5a16f798ac
12 changed files with 774 additions and 172 deletions
+157 -43
View File
@@ -40,18 +40,14 @@ class Tree {
}
void update() {
// Only play tree sound if not chopped and within 3 tiles distance (2 tiles on either side)
// Keep tree sound active so distance-based fade can work.
if (!is_chopped) {
if (abs(x - position) <= 3) {
if (sound_handle == -1 || !p.sound_is_active(sound_handle)) {
sound_handle = p.play_1d("sounds/environment/tree.ogg", x, position, true);
}
} else {
if (sound_handle != -1) {
p.destroy_sound(sound_handle);
sound_handle = -1;
}
if (sound_handle == -1 || !p.sound_is_active(sound_handle)) {
sound_handle = play_1d_tile("sounds/environment/tree.ogg", x, position, true);
}
} else if (sound_handle != -1) {
p.destroy_sound(sound_handle);
sound_handle = -1;
}
}
@@ -199,7 +195,7 @@ void damage_tree(int target_x, int damage) {
}
// Play the falling sound at the tree's position
p.play_1d("sounds/items/tree.ogg", x, target.position, false);
play_1d_tile("sounds/items/tree.ogg", x, target.position, false);
int sticks_dropped = random(1, 3);
int vines_dropped = random(1, 2);
@@ -228,10 +224,8 @@ void damage_tree(int target_x, int damage) {
void perform_search(int current_x)
{
// Check for Snares nearby (Current or Adjacent)
// "Shift beside the snare will collect the snare" -> adjacent
// We check current and +/- 1
for (int check_x = current_x - 1; check_x <= current_x + 1; check_x++) {
// Check for snares nearby (adjacent within range)
for (int check_x = current_x - SNARE_COLLECT_RANGE; check_x <= current_x + SNARE_COLLECT_RANGE; check_x++) {
// Skip current x? User said "beside". If on top, it breaks.
// But if I stand adjacent and shift...
if (check_x == current_x) continue; // Safety against collecting own snare you stand on? (Collision happens on move)
@@ -496,11 +490,14 @@ void start_falling() {
void update_falling() {
if (!falling) return;
// Get ground level (mountain elevation or 0)
int ground_level = get_mountain_elevation_at(x);
// Fall faster than climbing - 1 foot per 100ms
if (fall_timer.elapsed > 100) {
fall_timer.restart();
if (y > 0) {
if (y > ground_level) {
y--;
// Restart falling sound with decreasing pitch each foot
@@ -509,38 +506,155 @@ void update_falling() {
}
// Pitch ranges from 100 (high up) to 50 (near ground)
// Calculate based on current y position
float pitch_percent = 50.0 + (50.0 * (y / 30.0));
float height_above_ground = float(y - ground_level);
float pitch_percent = 50.0 + (50.0 * (height_above_ground / 30.0));
if (pitch_percent < 50.0) pitch_percent = 50.0;
if (pitch_percent > 100.0) pitch_percent = 100.0;
fall_sound_handle = p.play_stationary_extended("sounds/actions/falling.ogg", true, 0, 0, 0, pitch_percent);
// Check if we've reached ground level
if (y <= ground_level) {
land_on_ground(ground_level);
}
} else {
// Hit the ground
falling = false;
// Stop falling sound
if (fall_sound_handle != -1) {
p.destroy_sound(fall_sound_handle);
fall_sound_handle = -1;
}
p.play_stationary("sounds/actions/hit_ground.ogg", false);
// Calculate fall damage
int fall_height = fall_start_y;
if (fall_height > 10) {
int damage = 0;
for (int i = 10; i < fall_height; i++) {
damage += random(1, 3);
}
player_health -= damage;
screen_reader_speak("Fell " + fall_height + " feet! Took " + damage + " damage. " + player_health + " health remaining.", true);
} else {
screen_reader_speak("Landed safely.", true);
}
fall_start_y = 0;
land_on_ground(ground_level);
}
}
}
void land_on_ground(int ground_level) {
falling = false;
// Stop falling sound
if (fall_sound_handle != -1) {
p.destroy_sound(fall_sound_handle);
fall_sound_handle = -1;
}
p.play_stationary("sounds/actions/hit_ground.ogg", false);
// Calculate fall damage
int fall_height = fall_start_y - ground_level;
y = ground_level;
if (fall_height > 10) {
int damage = 0;
for (int i = 10; i < fall_height; i++) {
damage += random(1, 3);
}
player_health -= damage;
screen_reader_speak("Fell " + fall_height + " feet! Took " + damage + " damage. " + player_health + " health remaining.", true);
} else {
screen_reader_speak("Landed safely.", true);
}
fall_start_y = 0;
}
// Mountain movement check
bool can_move_mountain(int from_x, int to_x) {
MountainRange@ mountain = get_mountain_at(to_x);
if (mountain is null) {
// Not entering a mountain
return true;
}
// Check if from_x is also in same mountain
if (!mountain.contains_position(from_x)) {
// Entering mountain from edge - always allowed
return true;
}
// Check elevation change
if (mountain.is_steep_section(from_x, to_x)) {
// Need rope
if (inv_ropes < 1) {
screen_reader_speak("You'll need a rope to climb there.", true);
return false;
}
// Prompt for rope climb
int elevation_change = mountain.get_elevation_change(from_x, to_x);
if (elevation_change > 0) {
screen_reader_speak("Press up to climb up.", true);
} else {
screen_reader_speak("Press down to climb down.", true);
}
// Store pending rope climb info
pending_rope_climb_x = to_x;
pending_rope_climb_elevation = mountain.get_elevation_at(to_x);
return false;
}
return true;
}
// Rope climbing functions
void start_rope_climb(bool climbing_up, int target_x, int target_elevation) {
rope_climbing = true;
rope_climb_up = climbing_up;
rope_climb_target_x = target_x;
rope_climb_target_y = target_elevation;
rope_climb_start_y = y;
rope_climb_timer.restart();
int distance = rope_climb_target_y - y;
if (distance < 0) distance = -distance;
string direction = climbing_up ? "up" : "down";
screen_reader_speak("Climbing " + direction + ". " + distance + " feet.", true);
}
void update_rope_climbing() {
if (!rope_climbing) return;
// Climb at ROPE_CLIMB_SPEED ms per foot
if (rope_climb_timer.elapsed > ROPE_CLIMB_SPEED) {
rope_climb_timer.restart();
if (rope_climb_up) {
// Climbing up
if (y < rope_climb_target_y) {
y++;
p.play_stationary("sounds/actions/climb_rope.ogg", false);
if (y >= rope_climb_target_y) {
complete_rope_climb();
}
}
} else {
// Climbing down
if (y > rope_climb_target_y) {
y--;
p.play_stationary("sounds/actions/climb_rope.ogg", false);
if (y <= rope_climb_target_y) {
complete_rope_climb();
}
}
}
}
}
void complete_rope_climb() {
rope_climbing = false;
x = rope_climb_target_x;
y = rope_climb_target_y;
// Play footstep for new terrain
play_footstep(x, BASE_END, GRASS_END);
screen_reader_speak("Reached elevation " + y + ".", true);
}
void check_rope_climb_fall() {
if (!rope_climbing) return;
if (key_down(KEY_LEFT) || key_down(KEY_RIGHT)) {
// Fall from rope!
rope_climbing = false;
start_falling();
}
}