fix(render): restore animated playfield artwork
The gameplay renderer drew the inactive table and then placed thin line flippers and procedural circles over baked resting artwork. This left two flipper poses visible at once, made the ball difficult to see, and ignored recovered animation resources already embedded with the reconstruction. Build an alpha-masked texture from the original ball bitmap and mask, erase the baked flipper pose before drawing collision-aligned moving flippers, and animate the recovered wheel, robot, and magnet sheets from their gameplay events. Add bumper flashes, exact lit-table pixels for TILT, and a short visual table shake for nudges so contacts and machine state have immediate feedback. Test Plan: - `cargo fmt -- --check` -- passed - `cargo test --all-targets` -- passed - `cargo clippy --all-targets -- -D warnings` -- passed - launched the Linux window and inspected attract, gameplay, resting flippers, raised flipper cleanup, and the masked ball sprite -- passed - `git diff --check` -- passed
This commit is contained in:
+29
-2
@@ -2,7 +2,7 @@ use crate::geometry::{Segment, circle_collision, segment_collision};
|
||||
use macroquad::prelude::{Vec2, vec2};
|
||||
use std::sync::LazyLock;
|
||||
|
||||
const BALL_RADIUS: f32 = 5.0;
|
||||
const BALL_RADIUS: f32 = 7.0;
|
||||
const GRAVITY: f32 = 135.0;
|
||||
const MAX_SPEED: f32 = 430.0;
|
||||
const BALL_SEARCH_DELAY: f32 = 3.0;
|
||||
@@ -88,6 +88,10 @@ pub struct Game {
|
||||
pub tilted: bool,
|
||||
pub left_flipper_angle: f32,
|
||||
pub right_flipper_angle: f32,
|
||||
pub bumper_flash: [f32; 3],
|
||||
pub wheel_animation: f32,
|
||||
pub robot_animation: f32,
|
||||
pub nudge_shake: f32,
|
||||
pub finished: bool,
|
||||
accumulator: f32,
|
||||
target_cooldown: f32,
|
||||
@@ -112,6 +116,10 @@ impl Game {
|
||||
tilted: false,
|
||||
left_flipper_angle: -2.72,
|
||||
right_flipper_angle: -0.42,
|
||||
bumper_flash: [0.0; 3],
|
||||
wheel_animation: 0.0,
|
||||
robot_animation: 0.0,
|
||||
nudge_shake: 0.0,
|
||||
finished: false,
|
||||
accumulator: 0.0,
|
||||
target_cooldown: 0.0,
|
||||
@@ -172,6 +180,7 @@ impl Game {
|
||||
self.ball.velocity.x += controls.nudge * 55.0;
|
||||
self.nudge_meter += controls.nudge.abs() * 0.34;
|
||||
self.nudge_cooldown = 0.22;
|
||||
self.nudge_shake = 0.18;
|
||||
if self.nudge_meter >= TILT_THRESHOLD {
|
||||
self.tilted = true;
|
||||
self.bonus = 0;
|
||||
@@ -192,11 +201,18 @@ impl Game {
|
||||
events
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_lines)]
|
||||
fn fixed_update(&mut self, dt: f32, events: &mut Vec<Event>) {
|
||||
self.target_cooldown = (self.target_cooldown - dt).max(0.0);
|
||||
self.bumper_cooldown = (self.bumper_cooldown - dt).max(0.0);
|
||||
self.nudge_cooldown = (self.nudge_cooldown - dt).max(0.0);
|
||||
self.magnets = (self.magnets - dt).max(0.0);
|
||||
self.wheel_animation = (self.wheel_animation - dt).max(0.0);
|
||||
self.robot_animation = (self.robot_animation - dt).max(0.0);
|
||||
self.nudge_shake = (self.nudge_shake - dt).max(0.0);
|
||||
for flash in &mut self.bumper_flash {
|
||||
*flash = (*flash - dt).max(0.0);
|
||||
}
|
||||
if !self.tilted {
|
||||
self.nudge_meter = (self.nudge_meter - dt * 0.34).max(0.0);
|
||||
}
|
||||
@@ -243,7 +259,10 @@ impl Game {
|
||||
self.ball.velocity += vec2(20.0, -115.0);
|
||||
}
|
||||
|
||||
for center in [vec2(207.0, 109.0), vec2(167.0, 148.0), vec2(219.0, 167.0)] {
|
||||
for (index, center) in [vec2(207.0, 109.0), vec2(167.0, 148.0), vec2(219.0, 167.0)]
|
||||
.into_iter()
|
||||
.enumerate()
|
||||
{
|
||||
let hit = circle_collision(
|
||||
&mut self.ball.position,
|
||||
&mut self.ball.velocity,
|
||||
@@ -256,6 +275,7 @@ impl Game {
|
||||
self.add_score(self.player().bumper_value);
|
||||
self.bonus = self.bonus.saturating_add(100);
|
||||
self.bumper_cooldown = 0.08;
|
||||
self.bumper_flash[index] = 0.16;
|
||||
events.push(Event::Bumper);
|
||||
}
|
||||
}
|
||||
@@ -356,6 +376,7 @@ impl Game {
|
||||
self.wheel_holes[hole] = true;
|
||||
self.add_score(2_500);
|
||||
self.target_cooldown = 0.15;
|
||||
self.wheel_animation = 0.65;
|
||||
events.push(Event::Wheel);
|
||||
}
|
||||
if self.wheel_holes.iter().all(|hole| *hole) {
|
||||
@@ -368,6 +389,7 @@ impl Game {
|
||||
self.add_score(7_500);
|
||||
self.ball.velocity = vec2(-125.0, 60.0);
|
||||
self.target_cooldown = 0.3;
|
||||
self.robot_animation = 1.0;
|
||||
events.push(Event::Robot);
|
||||
}
|
||||
|
||||
@@ -377,6 +399,7 @@ impl Game {
|
||||
self.ball.position = vec2(185.0, 181.0);
|
||||
self.ball.velocity = vec2(-40.0 + f32::from(self.lock_lights) * 18.0, -120.0);
|
||||
self.target_cooldown = 0.4;
|
||||
self.robot_animation = 0.8;
|
||||
events.push(Event::Lock);
|
||||
}
|
||||
|
||||
@@ -441,6 +464,10 @@ impl Game {
|
||||
self.tilted = false;
|
||||
self.nudge_meter = 0.0;
|
||||
self.stalled_for = 0.0;
|
||||
self.bumper_flash.fill(0.0);
|
||||
self.wheel_animation = 0.0;
|
||||
self.robot_animation = 0.0;
|
||||
self.nudge_shake = 0.0;
|
||||
|
||||
let mut next = (self.current_player + 1) % self.players.len();
|
||||
for _ in 0..self.players.len() {
|
||||
|
||||
Reference in New Issue
Block a user