feat(game): add figure images
BIN
assets/figures/I.png
Normal file
|
After Width: | Height: | Size: 256 B |
BIN
assets/figures/J.png
Normal file
|
After Width: | Height: | Size: 371 B |
BIN
assets/figures/L.png
Normal file
|
After Width: | Height: | Size: 371 B |
BIN
assets/figures/O.png
Normal file
|
After Width: | Height: | Size: 262 B |
BIN
assets/figures/S.png
Normal file
|
After Width: | Height: | Size: 321 B |
BIN
assets/figures/T.png
Normal file
|
After Width: | Height: | Size: 321 B |
BIN
assets/figures/Z.png
Normal file
|
After Width: | Height: | Size: 320 B |
@@ -1,16 +1,24 @@
|
||||
import random
|
||||
from enum import Enum
|
||||
from pathlib import Path
|
||||
from typing import NamedTuple
|
||||
|
||||
import pygame
|
||||
from attr import define
|
||||
from pygame import Vector2 as Vec2
|
||||
|
||||
from .colors import TokyoNightNight
|
||||
from .path import BASE_PATH
|
||||
|
||||
|
||||
class FigureConfig(NamedTuple):
|
||||
shape: list[Vec2]
|
||||
color: str
|
||||
image: pygame.Surface
|
||||
|
||||
|
||||
def _load_image(filename: str) -> pygame.Surface:
|
||||
return pygame.image.load(BASE_PATH / "assets" / "figures" / filename)
|
||||
|
||||
|
||||
class Figure(Enum):
|
||||
@@ -22,6 +30,7 @@ class Figure(Enum):
|
||||
Vec2(0, 1),
|
||||
],
|
||||
TokyoNightNight().cyan,
|
||||
_load_image("I.png"),
|
||||
)
|
||||
O = FigureConfig(
|
||||
[
|
||||
@@ -31,6 +40,7 @@ class Figure(Enum):
|
||||
Vec2(1, -1),
|
||||
],
|
||||
TokyoNightNight().yellow,
|
||||
_load_image("O.png"),
|
||||
)
|
||||
T = FigureConfig(
|
||||
[
|
||||
@@ -40,6 +50,7 @@ class Figure(Enum):
|
||||
Vec2(0, -1),
|
||||
],
|
||||
TokyoNightNight().purple,
|
||||
_load_image("T.png"),
|
||||
)
|
||||
|
||||
S = FigureConfig(
|
||||
@@ -50,6 +61,7 @@ class Figure(Enum):
|
||||
Vec2(1, -1),
|
||||
],
|
||||
TokyoNightNight().green,
|
||||
_load_image("S.png"),
|
||||
)
|
||||
Z = FigureConfig(
|
||||
[
|
||||
@@ -59,6 +71,7 @@ class Figure(Enum):
|
||||
Vec2(-1, -1),
|
||||
],
|
||||
TokyoNightNight().red,
|
||||
_load_image("Z.png"),
|
||||
)
|
||||
J = FigureConfig(
|
||||
[
|
||||
@@ -68,6 +81,7 @@ class Figure(Enum):
|
||||
Vec2(-1, 1),
|
||||
],
|
||||
TokyoNightNight().blue,
|
||||
_load_image("J.png"),
|
||||
)
|
||||
L = FigureConfig(
|
||||
[
|
||||
@@ -77,6 +91,7 @@ class Figure(Enum):
|
||||
Vec2(1, 1),
|
||||
],
|
||||
TokyoNightNight().orange,
|
||||
_load_image("L.png"),
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
|
||||