feat: add collisions
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user