fix(av): restore original nudge and sound presentation
Remove the invented whole-frame nudge shake so nudges affect only recovered ball state, sound, and tilt behavior. Match monophonic SndPlaySound semantics by stopping the current WAV before each new resource and using full host mixer volume instead of an arbitrary 72 percent attenuation. Test Plan: - cargo test --all-targets - cargo clippy --all-targets --all-features -- -D warnings - rumdl check CHANGELOG.md RECONSTRUCTION.md README.md - git diff --check
This commit is contained in:
+2
-13
@@ -1192,21 +1192,10 @@ impl App {
|
||||
let height = HEIGHT * scale;
|
||||
let x = (screen_width() - width) * 0.5;
|
||||
let y = (screen_height() - height) * 0.5;
|
||||
let shake = self.game.as_ref().map_or(Vec2::ZERO, |game| {
|
||||
if game.nudge_shake <= 0.0 {
|
||||
return Vec2::ZERO;
|
||||
}
|
||||
let strength = (game.nudge_shake / 0.18).min(1.0) * 2.5 * scale;
|
||||
let phase = game.nudge_shake * 950.0;
|
||||
vec2(
|
||||
phase.sin() * strength,
|
||||
(phase * 0.73).cos() * strength * 0.45,
|
||||
)
|
||||
});
|
||||
draw_texture_ex(
|
||||
&self.render_target.texture,
|
||||
x + shake.x,
|
||||
y + shake.y,
|
||||
x,
|
||||
y,
|
||||
WHITE,
|
||||
DrawTextureParams {
|
||||
dest_size: Some(vec2(width, height)),
|
||||
|
||||
@@ -186,11 +186,12 @@ impl Assets {
|
||||
return;
|
||||
}
|
||||
if let Some((_, sound)) = self.sounds.iter().find(|(sound_id, _)| *sound_id == id) {
|
||||
self.stop_all_sounds();
|
||||
play_sound(
|
||||
sound,
|
||||
PlaySoundParams {
|
||||
looped: false,
|
||||
volume: 0.72,
|
||||
volume: 1.0,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
+14
-19
@@ -4,7 +4,7 @@ use crate::{
|
||||
geometry::Segment,
|
||||
original_physics::{
|
||||
CollisionMaterial, CollisionResponse, GRAVITY_MILLI_PER_STEP,
|
||||
MAXIMUM_SPEED_MILLI_PER_STEP, MilliVec, STEP_SECONDS, StaticCollisionCandidate,
|
||||
MAXIMUM_SPEED_MILLI_PER_STEP, MilliVec, StaticCollisionCandidate,
|
||||
ball_collision_response, capture_collision_candidate, circle_collision_candidate_at,
|
||||
line_collision_candidate_at, milli_distance, path_intersects_circle,
|
||||
},
|
||||
@@ -301,7 +301,6 @@ pub struct Game {
|
||||
pub claw: Claw,
|
||||
pub target_rotation_state: Option<u8>,
|
||||
pub panel_frame: Option<u16>,
|
||||
pub nudge_shake: f32,
|
||||
pub launcher_charge: f32,
|
||||
pub finished: bool,
|
||||
pub last_collision_id: Option<u8>,
|
||||
@@ -343,7 +342,6 @@ impl Game {
|
||||
claw: Claw::default(),
|
||||
target_rotation_state: None,
|
||||
panel_frame: None,
|
||||
nudge_shake: 0.0,
|
||||
launcher_charge: 0.0,
|
||||
finished: false,
|
||||
last_collision_id: None,
|
||||
@@ -499,7 +497,7 @@ impl Game {
|
||||
self.score_mode = ScoreMode::Multiball;
|
||||
}
|
||||
for _ in 0..substeps {
|
||||
if self.fixed_update(STEP_SECONDS, events)
|
||||
if self.fixed_update(events)
|
||||
|| self.finished
|
||||
|| self.claw.ball_suspended
|
||||
{
|
||||
@@ -677,7 +675,6 @@ impl Game {
|
||||
self.ball.velocity = velocity.to_velocity_per_second();
|
||||
}
|
||||
|
||||
self.nudge_shake = 0.18;
|
||||
self.tilt_counter = self.tilt_counter.wrapping_add(25);
|
||||
let threshold = self.random.below(10) + 30;
|
||||
if threshold < self.tilt_counter {
|
||||
@@ -692,8 +689,7 @@ impl Game {
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_lines)]
|
||||
fn fixed_update(&mut self, dt: f32, events: &mut Vec<Event>) -> bool {
|
||||
self.nudge_shake = (self.nudge_shake - dt).max(0.0);
|
||||
fn fixed_update(&mut self, events: &mut Vec<Event>) -> bool {
|
||||
if self.ball.in_launcher {
|
||||
self.ball.position = LAUNCHER_POSITION;
|
||||
self.ball.velocity = Vec2::ZERO;
|
||||
@@ -1963,7 +1959,6 @@ impl Game {
|
||||
self.pending_flipper_edges.fill(0);
|
||||
self.secondary_ball = None;
|
||||
self.score_mode = ScoreMode::Normal;
|
||||
self.nudge_shake = 0.0;
|
||||
self.launcher_charge = 0.0;
|
||||
self.launcher_was_down = false;
|
||||
self.launcher_hold_seconds = 0.0;
|
||||
@@ -2190,7 +2185,7 @@ mod tests {
|
||||
let mut expected_events = Vec::new();
|
||||
let mut stopped = false;
|
||||
for _ in 0..5 {
|
||||
if expected.fixed_update(STEP_SECONDS, &mut expected_events) {
|
||||
if expected.fixed_update(&mut expected_events) {
|
||||
stopped = true;
|
||||
break;
|
||||
}
|
||||
@@ -2757,7 +2752,7 @@ mod tests {
|
||||
game.ball.velocity = vec2(0.0, -380.0);
|
||||
|
||||
for _ in 0..5 {
|
||||
game.fixed_update(STEP_SECONDS, &mut Vec::new());
|
||||
game.fixed_update(&mut Vec::new());
|
||||
}
|
||||
|
||||
assert!(game.ball.position.y >= 15.0);
|
||||
@@ -2773,7 +2768,7 @@ mod tests {
|
||||
game.ball.capture_age = 42;
|
||||
|
||||
for _ in 0..5 {
|
||||
if game.fixed_update(STEP_SECONDS, &mut Vec::new()) {
|
||||
if game.fixed_update(&mut Vec::new()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -2867,7 +2862,7 @@ mod tests {
|
||||
weak.ball.position = vec2(165.0, 171.1);
|
||||
weak.ball.velocity = vec2(0.0, -20.0);
|
||||
let mut weak_events = Vec::new();
|
||||
assert!(weak.fixed_update(STEP_SECONDS, &mut weak_events));
|
||||
assert!(weak.fixed_update(&mut weak_events));
|
||||
|
||||
let mut fast = Game::new(1);
|
||||
fast.object_active.fill(false);
|
||||
@@ -2879,9 +2874,9 @@ mod tests {
|
||||
let mut tilted = fast.clone();
|
||||
tilted.tilted = true;
|
||||
let mut fast_events = Vec::new();
|
||||
assert!(fast.fixed_update(STEP_SECONDS, &mut fast_events));
|
||||
assert!(fast.fixed_update(&mut fast_events));
|
||||
let mut tilted_events = Vec::new();
|
||||
assert!(tilted.fixed_update(STEP_SECONDS, &mut tilted_events));
|
||||
assert!(tilted.fixed_update(&mut tilted_events));
|
||||
|
||||
assert_eq!(weak.player().score, 1_000);
|
||||
assert_eq!(fast.player().score, 2_000);
|
||||
@@ -3471,7 +3466,7 @@ mod tests {
|
||||
let mut expected_velocity = expected_response.velocity;
|
||||
expected_velocity.clamp_speed(MAXIMUM_SPEED_MILLI_PER_STEP);
|
||||
|
||||
assert!(game.fixed_update(STEP_SECONDS, &mut Vec::new()));
|
||||
assert!(game.fixed_update(&mut Vec::new()));
|
||||
|
||||
assert_eq!(game.last_collision_id, Some(5));
|
||||
assert_eq!(
|
||||
@@ -3601,7 +3596,7 @@ mod tests {
|
||||
.round_i32()
|
||||
.wrapping_sub(150);
|
||||
|
||||
assert!(!game.fixed_update(STEP_SECONDS, &mut Vec::new()));
|
||||
assert!(!game.fixed_update(&mut Vec::new()));
|
||||
|
||||
assert_eq!(
|
||||
MilliVec::from_velocity_per_second(game.ball.velocity),
|
||||
@@ -3625,7 +3620,7 @@ mod tests {
|
||||
game.ball.velocity = MilliVec { x: -3_000, y: 0 }.to_velocity_per_second();
|
||||
let old_position = MilliVec::from_position(game.ball.position);
|
||||
|
||||
assert!(game.fixed_update(STEP_SECONDS, &mut Vec::new()));
|
||||
assert!(game.fixed_update(&mut Vec::new()));
|
||||
|
||||
let velocity = MilliVec::from_velocity_per_second(game.ball.velocity);
|
||||
assert!(velocity.x > 0, "the type-three rim must reflect the ball");
|
||||
@@ -3647,7 +3642,7 @@ mod tests {
|
||||
game.ball.position = sensor.center + vec2(23.0, 0.0);
|
||||
game.ball.velocity = MilliVec { x: 3_800, y: 0 }.to_velocity_per_second();
|
||||
|
||||
game.fixed_update(STEP_SECONDS, &mut Vec::new());
|
||||
game.fixed_update(&mut Vec::new());
|
||||
|
||||
assert_eq!(game.record_contacts[usize::from(sensor.id)], 1);
|
||||
}
|
||||
@@ -3671,7 +3666,7 @@ mod tests {
|
||||
expected_game.randomize_trigger_velocity(&mut expected_ball);
|
||||
let expected_velocity = MilliVec::from_velocity_per_second(expected_ball.velocity);
|
||||
|
||||
game.fixed_update(STEP_SECONDS, &mut Vec::new());
|
||||
game.fixed_update(&mut Vec::new());
|
||||
|
||||
assert_eq!(game.player().score, 500);
|
||||
assert_eq!(
|
||||
|
||||
@@ -6,7 +6,6 @@ use macroquad::prelude::{Vec2, vec2};
|
||||
|
||||
use crate::real48::Real48;
|
||||
|
||||
pub const STEP_SECONDS: f32 = 0.010;
|
||||
pub const GRAVITY_MILLI_PER_STEP: i32 = 15;
|
||||
pub const MAXIMUM_SPEED_MILLI_PER_STEP: i32 = 3_800;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user