Fixes collision code.

This commit is contained in:
William Hubbard
2023-02-05 13:58:32 -07:00
parent b80c215d98
commit 518bf5f5e6
3 changed files with 6 additions and 9 deletions

View File

@@ -92,9 +92,7 @@ class Camera:
self.target = target
def entity_in_camera(self, ent_x, ent_y, ent_width = 0, ent_height = 0) -> bool:
if ent_x + ent_width >= self.x and ent_y + ent_height >= self.y and ent_x < self.x + self.width and ent_y < self.y + self.height:
return True
print("Dropping entity (%d, %d - %d, %d) from (%d, %d - %d, %d)" % (ent_x, ent_y, ent_x + ent_width, ent_y + ent_height, self.x, self.y, self.x + self.width, self.y + self.height))
return ent_x + ent_width >= self.x and ent_y + ent_height >= self.y and ent_x < self.x + self.width and ent_y < self.y + self.height
def relative_to_camera(self, global_x, global_y):
return (global_x - self.x, global_y - self.y)