diff --git a/src/py2048/block.py b/src/py2048/block.py index eba1846..8b895a5 100644 --- a/src/py2048/block.py +++ b/src/py2048/block.py @@ -62,8 +62,8 @@ class Block(pygame.sprite.Sprite): def _is_out_if_bounds(self, x: int, y: int) -> bool: """Return whether the block is out of bounds.""" return not ( - 0 <= x <= Config.WIDTH - Config.BLOCK_SIZE - and 0 <= y <= Config.HEIGHT - Config.BLOCK_SIZE + 0 <= x <= Config.GRID_WIDTH - Config.BLOCK_SIZE + and 0 <= y <= Config.GRID_HEIGHT - Config.BLOCK_SIZE ) def _has_collision(self, x: int, y: int) -> bool: diff --git a/src/py2048/config.py b/src/py2048/config.py index 5b64191..5b45dc4 100644 --- a/src/py2048/config.py +++ b/src/py2048/config.py @@ -4,6 +4,8 @@ class Config: GRID_SIZE = 4 BLOCK_SIZE = 50 WIDTH = GRID_SIZE * BLOCK_SIZE - HEIGHT = GRID_SIZE * BLOCK_SIZE + HEIGHT = GRID_SIZE * BLOCK_SIZE + 100 + GRID_HEIGHT = GRID_SIZE * BLOCK_SIZE + GRID_WIDTH = GRID_SIZE * BLOCK_SIZE INITIAL_BLOCK_COUNT = 2 BLOCK_VALUE_PROBABILITY = 0.9 diff --git a/src/py2048/game.py b/src/py2048/game.py index c319ff1..a608273 100644 --- a/src/py2048/game.py +++ b/src/py2048/game.py @@ -16,7 +16,9 @@ class Game: logger.info("Initializing game") pygame.init() - self.screen: pygame.Surface = pygame.display.set_mode((Config.WIDTH, Config.HEIGHT)) + self.screen: pygame.Surface = pygame.display.set_mode( + (Config.WIDTH, Config.HEIGHT) + ) pygame.display.set_caption("2048") self.blocks = Board(self.screen)