From 7b32969e72a83102eaa34951c6545bf42f01e2a9 Mon Sep 17 00:00:00 2001 From: Thilo Behnke Date: Sat, 9 Jul 2022 20:02:05 +0200 Subject: [PATCH] feature/fix-ball-bound-collision --- client/svelte-client/src/components/TickWrapper.svelte | 2 +- pong/src/pong.rs | 9 +-------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/client/svelte-client/src/components/TickWrapper.svelte b/client/svelte-client/src/components/TickWrapper.svelte index 9d65872..f52f342 100644 --- a/client/svelte-client/src/components/TickWrapper.svelte +++ b/client/svelte-client/src/components/TickWrapper.svelte @@ -30,7 +30,7 @@ fn(elapsed / 1_000, dt / 1_000); return; } - + const dtMs = now - lastTime; if (dtMs < frameThreshold) { return; diff --git a/pong/src/pong.rs b/pong/src/pong.rs index 34b553a..6f908ad 100644 --- a/pong/src/pong.rs +++ b/pong/src/pong.rs @@ -72,15 +72,8 @@ pub mod pong_collisions { let bound = RefCell::borrow(&bound); ball.vel_mut().reflect(&bound.orientation()); - // move out of collision - let mut bound_orientation = bound.orientation().clone(); - bound_orientation.switch(); - bound_orientation.abs(); - let mut bound_pos = bound.pos().clone(); - bound_pos.multiply(&bound_orientation); - + let bound_pos = bound.pos().clone(); let mut b_to_a = ball.pos().clone(); - b_to_a.multiply(&bound_orientation); b_to_a.sub(&bound_pos); b_to_a.normalize(); b_to_a.multiply(&ball_dimensions);