sep-pm-platformer/project/sprite/BoundingBox.py

19 lines
551 B
Python
Raw Normal View History

2023-03-25 15:41:32 +01:00
class BoundingBox:
def __init__(self, x, y, width, height):
self.x = x
self.y = y
self.width = width
self.height = height
def get_dimensions(self):
return self.width, self.height
def get_position(self):
return self.x, self.y
2023-03-25 17:18:43 +01:00
def contains_point(self, position: tuple[float, float]):
return self.x <= position[0] <= self.x + self.width and self.y <= position[1] <= self.y + self.height
2023-03-25 17:18:43 +01:00
def __str__(self):
return f"({self.x}, {self.y}, {self.width}, {self.height})"