game: fix: position is now calculate rightly
This commit is contained in:
parent
c32de0a2f4
commit
4ba4d393a5
@ -115,7 +115,10 @@ def get_impact_point(segments: list[Segment], ball: Ball):
|
|||||||
print("cos:", cos)
|
print("cos:", cos)
|
||||||
print("sin:", sin)
|
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)
|
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
|
diff_y: float = ball.position.y - impact.y
|
||||||
print("y:", diff_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
|
continue
|
||||||
print("OK: Y")
|
print("OK: Y")
|
||||||
|
|
||||||
print("OK: PARFAIT")
|
print("OK: PARFAIT", impact)
|
||||||
|
|
||||||
impact.x += (ball.size / 2) * get_sign(cos) * (-1)
|
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)):
|
if (closest is None or impact.distance(ball.position) < closest.distance(ball.position)):
|
||||||
closest = impact
|
closest = impact
|
||||||
|
Loading…
Reference in New Issue
Block a user