aboutsummaryrefslogtreecommitdiff
path: root/apps/fparkan-game/src/main.rs
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2026-11-26 19:09:41 +0300
committerValentin Popov <valentin@popov.link>2026-11-26 19:09:41 +0300
commit2e0a4571af587f28ba5ea580f177a225d0d352e2 (patch)
treeaf456896c423edd6bc8b45666e64f46689cd7bcf /apps/fparkan-game/src/main.rs
parent4367287f9e07aca6a173a5eaef641a75918d66e0 (diff)
downloadfparkan-2e0a4571af587f28ba5ea580f177a225d0d352e2.tar.xz
fparkan-2e0a4571af587f28ba5ea580f177a225d0d352e2.zip
fix(audio): attach the engine loop to the player's missile
Prepare velocity-driven Op2 sounds with the projectile's CTL attachment. Move their source with the active flight and stop it when the flight ends or its slot is reused. Keep launch as a separate one-shot. The GOG phase function confirms the missile's 0 to 1 phase range. In the stock Firing Line window the engine loop began at the tail and stopped on terrain contact.
Diffstat (limited to 'apps/fparkan-game/src/main.rs')
-rw-r--r--apps/fparkan-game/src/main.rs10
1 files changed, 7 insertions, 3 deletions
diff --git a/apps/fparkan-game/src/main.rs b/apps/fparkan-game/src/main.rs
index 8005faa7..b00605ab 100644
--- a/apps/fparkan-game/src/main.rs
+++ b/apps/fparkan-game/src/main.rs
@@ -22,6 +22,7 @@ mod player_collision;
mod player_fire;
mod player_footsteps;
mod projectile_render;
+mod projectile_sound;
mod projectile_trail;
mod shield_effects;
mod shot_sound;
@@ -10598,9 +10599,7 @@ impl StaticVulkanApp {
let Some(flight) = instance.flight else {
continue;
};
- let forward = flight.direction;
- let right = normalize3(cross3(forward, [0.0, 0.0, 1.0])).unwrap_or([1.0, 0.0, 0.0]);
- let up = cross3(right, forward);
+ let [right, forward, up] = projectile_render::flight_basis(flight.direction);
let rotate = |[x, y, z]: [f32; 3]| {
add3(add3(scale3(right, x), scale3(forward, y)), scale3(up, z))
};
@@ -11669,6 +11668,11 @@ impl StaticVulkanApp {
audio
.update_listener(camera.position, camera.forward, camera.up)
.map_err(|error| format!("update audio listener: {error}"))?;
+ projectile_sound::update(
+ audio,
+ &mut self.projectile_draws,
+ self.control_sound_slots.len(),
+ )?;
for (id, sound) in self.control_sound_slots.iter_mut().enumerate() {
let slot = &mut sound.effect;
if self