game: fix: collision work in 1v1
This commit is contained in:
parent
fe98a0f52f
commit
d54ef03aa4
@ -42,7 +42,7 @@ def get_derive(segment: Segment) -> float:
|
|||||||
if (segment.start.x == segment.stop.x):
|
if (segment.start.x == segment.stop.x):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
return (segment.stop.y - segment.start.y) / (segment.stop.x - segment.stop.y)
|
return (segment.stop.y - segment.start.y) / (segment.stop.x - segment.start.x)
|
||||||
|
|
||||||
def get_intercept(derive: float, point: Point) -> float:
|
def get_intercept(derive: float, point: Point) -> float:
|
||||||
|
|
||||||
@ -130,13 +130,13 @@ def get_impact_point(segments: list[Segment], ball: Ball):
|
|||||||
|
|
||||||
diff_x: float = ball.position.x - impact.x
|
diff_x: float = ball.position.x - impact.x
|
||||||
print("x:", diff_x)
|
print("x:", diff_x)
|
||||||
if (get_sign(diff_x) != get_sign(cos)):
|
if (get_sign(diff_x) == get_sign(cos) and cos != 0):
|
||||||
continue
|
continue
|
||||||
print("OK: X")
|
print("OK: X")
|
||||||
|
|
||||||
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)):
|
if (get_sign(diff_y) == get_sign(sin) and sin != 0):
|
||||||
continue
|
continue
|
||||||
print("OK: Y")
|
print("OK: Y")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user