From 4ba4d393a57c29d27d64513dbb0fef046b32a525 Mon Sep 17 00:00:00 2001 From: starnakin Date: Fri, 2 Feb 2024 16:37:31 +0100 Subject: [PATCH] game: fix: position is now calculate rightly --- games/routine.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/games/routine.py b/games/routine.py index 3e61d46..f02ce05 100644 --- a/games/routine.py +++ b/games/routine.py @@ -115,7 +115,10 @@ def get_impact_point(segments: list[Segment], ball: Ball): print("cos:", cos) print("sin:", sin) - point: Point = Point(ball.position.x + cos, ball.position.y + sin) + point: Point = Point(ball.position.x + cos, ball.position.y - sin) + + print(ball.position) + print(point) ball_segment = Segment(ball.position, point) @@ -136,14 +139,14 @@ def get_impact_point(segments: list[Segment], ball: Ball): diff_y: float = ball.position.y - impact.y print("y:", diff_y) - if (get_sign(diff_y) == get_sign(sin) and sin != 0): + if (get_sign(diff_y) != get_sign(sin) and sin != 0): continue print("OK: Y") - print("OK: PARFAIT") + print("OK: PARFAIT", impact) impact.x += (ball.size / 2) * get_sign(cos) * (-1) - impact.y += (ball.size / 2) * get_sign(sin) * (-1) + impact.y += (ball.size / 2) * get_sign(sin) if (closest is None or impact.distance(ball.position) < closest.distance(ball.position)): closest = impact