-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathams.py
More file actions
62 lines (51 loc) · 1.83 KB
/
Copy pathams.py
File metadata and controls
62 lines (51 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import pygame
from circle_clock import CircleClock
class AMS:
@staticmethod
def get_suggestion(
targetX: int,
targetY: int,
markerX: int,
markerY: int,
tolerance: int | float = 60,
towards: bool | None = None,
) -> bool:
if towards == False:
return towards
return (
targetX - tolerance <= markerX <= targetX + tolerance
and targetY - tolerance <= markerY <= targetY + tolerance
)
@staticmethod
def draw_arrow(screen: pygame.Surface, clock: CircleClock, angle: float):
center_point = clock.target.center
t_radius = clock.target.radius
"""
P1
/\
/ \
/ \
/ \
/ \
/ P3 P6 \
P2 ---| |--- P7
| |
| |
| |
| |
|____|
P4 P5
"""
P1 = (center_point[0], center_point[1] - t_radius * 0.5)
P2 = (center_point[0] - 0.10 * t_radius, center_point[1] - t_radius * 0.3)
P3 = (center_point[0] - 0.05 * t_radius, center_point[1] - t_radius * 0.3)
P4 = (center_point[0] - 0.05 * t_radius, center_point[1] + t_radius * 0.3)
P5 = (center_point[0] + 0.05 * t_radius, center_point[1] + t_radius * 0.3)
P6 = (center_point[0] + 0.05 * t_radius, center_point[1] - t_radius * 0.3)
P7 = (center_point[0] + 0.10 * t_radius, center_point[1] - t_radius * 0.3)
points = [P1, P2, P3, P4, P5, P6, P7]
pp = pygame.math.Vector2((center_point[0], center_point[1]))
rotated_points = [
(pygame.math.Vector2(x, y) - pp).rotate(angle) + pp for x, y in points
]
pygame.draw.polygon(surface=screen, color=(0, 0, 0), points=rotated_points)