from sprite.Sprite import Sprite from sprite.Spritesheet import Spritesheet class StaticSprite(Sprite): def __init__(self, spritesheet: Spritesheet): super().__init__(spritesheet) def collides_with(self, collider: 'StaticSprite', tolerance: float = 0.0): if not self.is_collider or not collider.is_collider: return False self_bounds = self.get_bounding_box() other_bounds = collider.get_bounding_box() self_dimensions = self_bounds.get_dimensions() other_dimensions = other_bounds.get_dimensions() self_position = self_bounds.get_position() other_position = other_bounds.get_position() if self_position[0] + self_dimensions[0] < other_position[0] + tolerance: return False if self_position[0] > other_position[0] + other_dimensions[0] - tolerance: return False if self_position[1] + self_dimensions[1] < other_position[1] + tolerance: return False if self_position[1] > other_position[1] + other_dimensions[1] - tolerance: return False return True