diff --git a/assets/figures/I.png b/assets/figures/I.png index 4dcc61a..1edc333 100644 Binary files a/assets/figures/I.png and b/assets/figures/I.png differ diff --git a/assets/figures/J.png b/assets/figures/J.png index 81d019d..2f05b79 100644 Binary files a/assets/figures/J.png and b/assets/figures/J.png differ diff --git a/assets/figures/L.png b/assets/figures/L.png index dc47d26..697e897 100644 Binary files a/assets/figures/L.png and b/assets/figures/L.png differ diff --git a/assets/figures/O.png b/assets/figures/O.png index d8dde52..32d17e1 100644 Binary files a/assets/figures/O.png and b/assets/figures/O.png differ diff --git a/assets/figures/S.png b/assets/figures/S.png index 80126a3..4e0cdba 100644 Binary files a/assets/figures/S.png and b/assets/figures/S.png differ diff --git a/assets/figures/T.png b/assets/figures/T.png index 9c9f74f..0bd7730 100644 Binary files a/assets/figures/T.png and b/assets/figures/T.png differ diff --git a/assets/figures/Z.png b/assets/figures/Z.png index 773bbde..b310a68 100644 Binary files a/assets/figures/Z.png and b/assets/figures/Z.png differ diff --git a/src/game/screens/preview.py b/src/game/screens/preview.py index 3a761dc..29e1773 100644 --- a/src/game/screens/preview.py +++ b/src/game/screens/preview.py @@ -30,7 +30,7 @@ class Preview(BaseScreen, SceenElement): Args: next_figures: Next figure. """ - self.next_figure = next_figure + self.next_figure: Figure = next_figure def draw(self) -> None: """Draw the preview on the preview surface.""" @@ -51,9 +51,10 @@ class Preview(BaseScreen, SceenElement): def _draw_figure(self) -> None: """Draw a single upcoming figure on the preview surface.""" - figure_surface = self.next_figure.value.image + figure_surface: pygame.Surface = self.next_figure.value.image() x = self.surface.get_width() / 2 y = self.surface.get_height() / 2 + figure_surface.fill(self.next_figure.value.color, special_flags=pygame.BLEND_RGB_MULT) rect = figure_surface.get_rect(center=(x, y)) self.surface.blit(figure_surface, rect) diff --git a/src/utils/__init__.py b/src/utils/__init__.py index 1c42e46..c6dec43 100644 --- a/src/utils/__init__.py +++ b/src/utils/__init__.py @@ -1,6 +1,6 @@ from .config import CONFIG from .enum import Direction, GameMode, Rotation -from .figure import Figure, FigureConfig +from .figure import Figure from .path import BASE_PATH from .settings import read_settings, save_settings from .tuples import Size @@ -10,7 +10,6 @@ __all__ = [ "CONFIG", "Size", "Figure", - "FigureConfig", "Direction", "Rotation", "GameMode", diff --git a/src/utils/figure.py b/src/utils/figure.py index 5667028..c504d63 100644 --- a/src/utils/figure.py +++ b/src/utils/figure.py @@ -1,30 +1,32 @@ import random from enum import Enum -from typing import NamedTuple import pygame +from attrs import define from pygame import Vector2 as Vec2 from .config import CONFIG from .path import BASE_PATH -class FigureConfig(NamedTuple): +@define +class FigureParams: """ Attributes: shape: The shape of the figure. color: The color of the figure. filename: The filename of the image of the figure. - image: The image of the figure. """ shape: list[Vec2] color: str filename: str - @property def image(self) -> pygame.Surface: - # TODO: change colors of images + """ + Returns: + The image of the figure. + """ return pygame.image.load(BASE_PATH / "assets" / "figures" / self.filename).convert_alpha() @@ -40,7 +42,7 @@ class Figure(Enum): L: The L figure. """ - I = FigureConfig( + I = FigureParams( # type: ignore [ Vec2(0, 0), Vec2(0, -1), @@ -50,7 +52,7 @@ class Figure(Enum): CONFIG.colors.cyan, "I.png", ) - O = FigureConfig( + O = FigureParams( # type: ignore [ Vec2(0, 0), Vec2(0, -1), @@ -60,7 +62,7 @@ class Figure(Enum): CONFIG.colors.yellow, "O.png", ) - T = FigureConfig( + T = FigureParams( # type: ignore [ Vec2(0, 0), Vec2(-1, 0), @@ -71,7 +73,7 @@ class Figure(Enum): "T.png", ) - S = FigureConfig( + S = FigureParams( # type: ignore [ Vec2(0, 0), Vec2(-1, 0), @@ -81,7 +83,7 @@ class Figure(Enum): CONFIG.colors.green, "S.png", ) - Z = FigureConfig( + Z = FigureParams( # type: ignore [ Vec2(0, 0), Vec2(1, 0), @@ -91,7 +93,7 @@ class Figure(Enum): CONFIG.colors.red, "Z.png", ) - J = FigureConfig( + J = FigureParams( # type: ignore [ Vec2(0, 0), Vec2(0, -1), @@ -101,7 +103,7 @@ class Figure(Enum): CONFIG.colors.blue, "J.png", ) - L = FigureConfig( + L = FigureParams( # type: ignore [ Vec2(0, 0), Vec2(0, -1),