mirror of
https://github.com/kristoferssolo/2048.git
synced 2025-10-21 15:20:35 +00:00
fix(game): list index out of range
This commit is contained in:
parent
d2f898358b
commit
276ed26aee
@ -59,6 +59,9 @@ class Block(pygame.sprite.Sprite):
|
|||||||
|
|
||||||
def _has_collision(self, x: int, y: int) -> bool:
|
def _has_collision(self, x: int, y: int) -> bool:
|
||||||
"""Checks whether the block has a collision with any other block."""
|
"""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)
|
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]:
|
def _get_collided_block(self, x: int, y: int) -> Union["Block", None]:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user