diff --git a/src/game/game.py b/src/game/game.py index 09edc63..b82c7f5 100644 --- a/src/game/game.py +++ b/src/game/game.py @@ -11,42 +11,53 @@ class Game: self.rect = self.surface.get_rect(topleft=CONFIG.game.pos) self.surface.fill(CONFIG.colors.bg_float) + self._create_grid_surface() + self.sprites = pygame.sprite.Group() self.tetromino = Tetromino(None, group=self.sprites) def run(self) -> None: self.dispaly_surface.blit(self.surface, CONFIG.game.pos) + self.draw() def draw(self) -> None: - self._draw_grid() - self._draw_border() self.sprites.draw(self.surface) + self._draw_border() + self._draw_grid() + + def _create_grid_surface(self) -> None: + self.grid_surface = self.surface.copy() + self.grid_surface.fill("#00ff00") + self.grid_surface.set_colorkey("#00ff00") + self.grid_surface.set_alpha(100) def _draw_grid(self) -> None: for col in range(1, CONFIG.game.columns): x = col * CONFIG.game.cell.width pygame.draw.line( - self.surface, + self.grid_surface, CONFIG.colors.border_highlight, (x, 0), - (x, self.surface.get_height()), + (x, self.grid_surface.get_height()), CONFIG.game.line_width, ) for row in range(1, CONFIG.game.rows): y = row * CONFIG.game.cell.width pygame.draw.line( - self.surface, + self.grid_surface, CONFIG.colors.border_highlight, (0, y), - (self.surface.get_width(), y), + (self.grid_surface.get_width(), y), CONFIG.game.line_width, ) + self.surface.blit(self.grid_surface, (0, 0)) + def _draw_border(self) -> None: pygame.draw.rect( self.dispaly_surface, CONFIG.colors.border_highlight, self.rect, - CONFIG.game.line_width, + CONFIG.game.line_width * 2, CONFIG.game.border_radius, ) diff --git a/src/game/main.py b/src/game/main.py index cb9c304..9d818bf 100644 --- a/src/game/main.py +++ b/src/game/main.py @@ -22,7 +22,6 @@ class Main: def draw(self) -> None: pygame.display.update() - self.game.draw() def run(self) -> None: while True: diff --git a/src/utils/config.py b/src/utils/config.py index b2eea93..91528e7 100644 --- a/src/utils/config.py +++ b/src/utils/config.py @@ -12,12 +12,12 @@ class Game: columns: int = 10 rows: int = 20 line_width: int = 1 - border_radius: int = 2 + border_radius: int = 5 padding: int = PADDING cell: Size = Size(40, 40) size: Size = Size(columns * cell.width, rows * cell.width) pos: Vec2 = Vec2(padding, padding) - offset: Vec2 = Vec2(columns // 2, -1) + offset: Vec2 = Vec2(columns // 2, 5) @define