Fixed sound back to th way it was before mostly.
This commit is contained in:
@@ -376,6 +376,6 @@ void main()
|
||||
}
|
||||
|
||||
// Audio Listener Update
|
||||
update_listener_tile(x);
|
||||
p.update_listener_1d(x);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,9 +106,9 @@ void update_sound_range_1d_tile(int slot, int range_tiles)
|
||||
|
||||
int play_1d_with_volume_step(string sound_file, int listener_x, int sound_x, bool looping, float volume_step)
|
||||
{
|
||||
int slot = p.play_1d(sound_file, to_audio_position(listener_x), to_audio_position(sound_x), looping);
|
||||
int slot = p.play_1d(sound_file, listener_x, sound_x, looping);
|
||||
if (slot != -1) {
|
||||
p.update_sound_positioning_values(slot, -1.0, to_audio_volume_step(volume_step), true);
|
||||
p.update_sound_positioning_values(slot, -1.0, volume_step, true);
|
||||
}
|
||||
return slot;
|
||||
}
|
||||
|
||||
@@ -161,7 +161,7 @@ void release_sling_attack(int player_x) {
|
||||
Tree@ tree = get_tree_at(check_x);
|
||||
if (tree != null && !tree.is_chopped) {
|
||||
// Stone hits tree but doesn't damage it
|
||||
play_1d_tile("sounds/weapons/sling_hit.ogg", player_x, check_x, false);
|
||||
p.play_1d("sounds/weapons/sling_hit.ogg", player_x, check_x, false);
|
||||
screen_reader_speak("Stone hit tree at " + check_x + ".", true);
|
||||
return;
|
||||
}
|
||||
@@ -179,11 +179,11 @@ void release_sling_attack(int player_x) {
|
||||
// Damage the correct enemy type
|
||||
if (hit_bandit) {
|
||||
damage_bandit_at(target_x, damage);
|
||||
play_1d_tile("sounds/weapons/sling_hit.ogg", player_x, target_x, false);
|
||||
p.play_1d("sounds/weapons/sling_hit.ogg", player_x, target_x, false);
|
||||
play_1d_with_volume_step("sounds/enemies/zombie_hit.ogg", player_x, target_x, false, BANDIT_SOUND_VOLUME_STEP);
|
||||
} else {
|
||||
damage_zombie_at(target_x, damage);
|
||||
play_1d_tile("sounds/weapons/sling_hit.ogg", player_x, target_x, false);
|
||||
p.play_1d("sounds/weapons/sling_hit.ogg", player_x, target_x, false);
|
||||
play_1d_with_volume_step("sounds/enemies/zombie_hit.ogg", player_x, target_x, false, ZOMBIE_SOUND_VOLUME_STEP);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,12 +93,12 @@ const int BANDIT_WANDER_DIRECTION_CHANGE_MAX = 8000;
|
||||
const int AUDIO_TILE_SCALE = 10;
|
||||
const float AUDIO_PAN_STEP = 2.0;
|
||||
const float AUDIO_VOLUME_STEP = 3.0;
|
||||
const int SNARE_SOUND_RANGE = 5;
|
||||
const int SNARE_SOUND_RANGE = 2;
|
||||
const float SNARE_SOUND_VOLUME_STEP = 4.0; // More audible for locating snares
|
||||
const float SNARE_SOUND_PAN_STEP = 4.0; // Stronger pan for direction
|
||||
const int SNARE_COLLECT_RANGE = 2;
|
||||
const int SNARE_COLLECT_RANGE = 1;
|
||||
|
||||
const int FIRE_SOUND_RANGE = 6;
|
||||
const int FIRE_SOUND_RANGE = 3;
|
||||
const float FIRE_SOUND_VOLUME_STEP = 5.0; // 30 dB over 6 tiles
|
||||
|
||||
const int FIREPIT_SOUND_RANGE = 5;
|
||||
|
||||
@@ -40,10 +40,18 @@ class Tree {
|
||||
}
|
||||
|
||||
void update() {
|
||||
// Keep tree sound active so distance-based fade can work.
|
||||
// Only play tree sound if not chopped and within 3 tiles distance
|
||||
if (!is_chopped) {
|
||||
int tree_distance = x - position;
|
||||
if (tree_distance < 0) tree_distance = -tree_distance;
|
||||
|
||||
if (tree_distance <= 3) {
|
||||
if (sound_handle == -1 || !p.sound_is_active(sound_handle)) {
|
||||
sound_handle = play_1d_tile("sounds/environment/tree.ogg", x, position, true);
|
||||
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;
|
||||
}
|
||||
} else if (sound_handle != -1) {
|
||||
p.destroy_sound(sound_handle);
|
||||
@@ -195,7 +203,7 @@ void damage_tree(int target_x, int damage) {
|
||||
}
|
||||
|
||||
// Play the falling sound at the tree's position
|
||||
play_1d_tile("sounds/items/tree.ogg", x, target.position, false);
|
||||
p.play_1d("sounds/items/tree.ogg", x, target.position, false);
|
||||
|
||||
int sticks_dropped = random(1, 3);
|
||||
int vines_dropped = random(1, 2);
|
||||
|
||||
@@ -114,13 +114,20 @@ class WorldSnare {
|
||||
minute_timer.restart();
|
||||
}
|
||||
|
||||
// Keep snare sound active so distance-based fade can work.
|
||||
int snare_distance = x - position;
|
||||
if (snare_distance < 0) snare_distance = -snare_distance;
|
||||
|
||||
if (snare_distance <= SNARE_SOUND_RANGE) {
|
||||
if (sound_handle == -1 || !p.sound_is_active(sound_handle)) {
|
||||
sound_handle = play_1d_tile("sounds/actions/set_snare.ogg", x, position, true);
|
||||
sound_handle = p.play_1d("sounds/actions/set_snare.ogg", x, position, true);
|
||||
if (sound_handle != -1) {
|
||||
p.update_sound_positioning_values(sound_handle, SNARE_SOUND_PAN_STEP, to_audio_volume_step(SNARE_SOUND_VOLUME_STEP), true);
|
||||
p.update_sound_positioning_values(sound_handle, SNARE_SOUND_PAN_STEP, SNARE_SOUND_VOLUME_STEP, true);
|
||||
}
|
||||
}
|
||||
} else if (sound_handle != -1) {
|
||||
p.destroy_sound(sound_handle);
|
||||
sound_handle = -1;
|
||||
}
|
||||
|
||||
// Every minute logic (only when active)
|
||||
if (active && minute_timer.elapsed >= 60000) {
|
||||
@@ -211,14 +218,21 @@ class WorldFire {
|
||||
}
|
||||
}
|
||||
|
||||
// Keep fire sound active while burning so distance-based fade can work.
|
||||
// Hard cutoff for fire sound.
|
||||
if (is_burning()) {
|
||||
int fire_distance = x - position;
|
||||
if (fire_distance < 0) fire_distance = -fire_distance;
|
||||
if (fire_distance <= FIRE_SOUND_RANGE) {
|
||||
if (sound_handle == -1 || !p.sound_is_active(sound_handle)) {
|
||||
sound_handle = play_1d_tile("sounds/items/fire.ogg", x, position, true);
|
||||
sound_handle = p.play_1d("sounds/items/fire.ogg", x, position, true);
|
||||
if (sound_handle != -1) {
|
||||
p.update_sound_positioning_values(sound_handle, -1.0, to_audio_volume_step(FIRE_SOUND_VOLUME_STEP), true);
|
||||
p.update_sound_positioning_values(sound_handle, -1.0, FIRE_SOUND_VOLUME_STEP, true);
|
||||
}
|
||||
}
|
||||
} else if (sound_handle != -1) {
|
||||
p.destroy_sound(sound_handle);
|
||||
sound_handle = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -322,13 +336,13 @@ class WorldStream {
|
||||
|
||||
// Keep stream sound active so distance-based fade can work.
|
||||
if (sound_handle == -1 || !p.sound_is_active(sound_handle)) {
|
||||
sound_handle = play_1d_tile("sounds/terrain/stream.ogg", x, sound_pos, true);
|
||||
sound_handle = p.play_1d("sounds/terrain/stream.ogg", x, sound_pos, true);
|
||||
sound_position = sound_pos;
|
||||
if (sound_handle != -1) {
|
||||
p.update_sound_positioning_values(sound_handle, -1.0, to_audio_volume_step(STREAM_SOUND_VOLUME_STEP), true);
|
||||
p.update_sound_positioning_values(sound_handle, -1.0, STREAM_SOUND_VOLUME_STEP, true);
|
||||
}
|
||||
} else if (sound_position != sound_pos) {
|
||||
update_sound_1d_tile(sound_handle, sound_pos);
|
||||
p.update_sound_1d(sound_handle, sound_pos);
|
||||
sound_position = sound_pos;
|
||||
}
|
||||
}
|
||||
@@ -1186,13 +1200,13 @@ class MountainRange {
|
||||
// Keep nearest stream sound active so distance-based fade can work.
|
||||
if (nearest_stream != -1) {
|
||||
if (stream_sound_handle == -1 || !p.sound_is_active(stream_sound_handle)) {
|
||||
stream_sound_handle = play_1d_tile("sounds/terrain/stream.ogg", x, nearest_stream, true);
|
||||
stream_sound_handle = p.play_1d("sounds/terrain/stream.ogg", x, nearest_stream, true);
|
||||
stream_sound_position = nearest_stream;
|
||||
if (stream_sound_handle != -1) {
|
||||
p.update_sound_positioning_values(stream_sound_handle, -1.0, to_audio_volume_step(MOUNTAIN_STREAM_VOLUME_STEP), true);
|
||||
p.update_sound_positioning_values(stream_sound_handle, -1.0, MOUNTAIN_STREAM_VOLUME_STEP, true);
|
||||
}
|
||||
} else if (stream_sound_position != nearest_stream) {
|
||||
update_sound_1d_tile(stream_sound_handle, nearest_stream);
|
||||
p.update_sound_1d(stream_sound_handle, nearest_stream);
|
||||
stream_sound_position = nearest_stream;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user