mirror of
https://github.com/kristoferssolo/2048.git
synced 2026-02-04 05:52:03 +00:00
fix(game): list index out of range
This commit is contained in:
@@ -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]:
|
||||
|
||||
Reference in New Issue
Block a user