diff --git a/src/game/game.py b/src/game/game.py index fa61967..09edc63 100644 --- a/src/game/game.py +++ b/src/game/game.py @@ -1,5 +1,7 @@ import pygame -from utils import CONFIG +from utils import CONFIG, Figure + +from .tetromino import Tetromino class Game: @@ -10,6 +12,7 @@ class Game: self.surface.fill(CONFIG.colors.bg_float) 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) diff --git a/src/game/tetromino.py b/src/game/tetromino.py new file mode 100644 index 0000000..acd0871 --- /dev/null +++ b/src/game/tetromino.py @@ -0,0 +1,18 @@ +from typing import Optional + +import pygame +from utils import CONFIG, Figure, FigureConfig, Size + +from .block import Block + + +class Tetromino: + def __init__(self, shape: Optional[Figure], /, group: pygame.sprite.Group) -> None: + self.figure: FigureConfig = shape.value if shape else Figure.random().value + self.block_positions: list[pygame.Vector2] = self.figure.shape + self.color: str = self.figure.color + + self.blocks = [ + Block(group=group, pos=pos, color=self.color) + for pos in self.block_positions + ]