fix(game): list index out of range

This commit is contained in:
Kristofers Solo 2023-12-31 22:45:01 +02:00
parent d2f898358b
commit 276ed26aee

View File

@ -59,6 +59,9 @@ class Block(pygame.sprite.Sprite):
def _has_collision(self, x: int, y: int) -> bool:
"""Checks whether the block has a collision with any other block."""
groups = self.groups()
if not groups or not groups[0]:
return False
return any(block.rect.collidepoint(x, y) for block in self.groups()[0] if block != self)
def _get_collided_block(self, x: int, y: int) -> Union["Block", None]: