pong online: fix: y axe paddle collision

This commit is contained in:
starnakin 2024-05-15 13:01:13 +02:00
parent 96c99a6f2d
commit f60b85a1bd

View File

@ -126,7 +126,6 @@ def get_impact_point(segment: Segment, ball_segment: Segment) -> Point | None:
return impact
def get_first_impact(segments: list[Segment], ball: Ball):
cos: float = round(math.cos(ball.angle), 6)
@ -215,6 +214,7 @@ def paddle_collision(impact: Point, player: PongPlayer, inc_x: float, inc_y: flo
paddle_angle: float = paddle.angle()
normal: float = paddle_angle - math.pi / 2
normal: float = math.atan2(math.sin(normal) * -1, math.cos(normal))
start_distance: float = paddle.start.distance(impact)
stop_distance: float = paddle.stop.distance(impact)
@ -224,7 +224,7 @@ def paddle_collision(impact: Point, player: PongPlayer, inc_x: float, inc_y: flo
hit_percent = round(hit_percent, 1)
new_angle: float = normal + (math.pi * 0.85) * (hit_percent - 0.5)
return new_angle
def wall_collision(ball_angle: float, wall: Segment) -> float: