feat: add collisions

This commit is contained in:
2025-10-18 21:02:24 +02:00
parent 45ed1c85c8
commit 09f70223b8
7 changed files with 89 additions and 0 deletions

View File

@@ -61,3 +61,8 @@ class Vec:
cos(angle) * self.x - sin(angle) * self.y,
sin(angle) * self.x + cos(angle) * self.y,
)
def within(self, p1: Vec, p2: Vec) -> bool:
x1, x2 = min(p1.x, p2.x), max(p1.x, p2.x)
y1, y2 = min(p1.y, p2.y), max(p1.y, p2.y)
return (x1 <= self.x <= x2) and (y1 <= self.y <= y2)