mirror of
https://github.com/kristoferssolo/Tetris.git
synced 2025-10-21 20:00:35 +00:00
refactor(game): use attrs
This commit is contained in:
parent
75d873d1eb
commit
38301b0688
@ -1,15 +1,16 @@
|
|||||||
import random
|
import random
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
from typing import NamedTuple
|
|
||||||
|
|
||||||
import pygame
|
import pygame
|
||||||
|
from attrs import define
|
||||||
from pygame import Vector2 as Vec2
|
from pygame import Vector2 as Vec2
|
||||||
|
|
||||||
from .config import CONFIG
|
from .config import CONFIG
|
||||||
from .path import BASE_PATH
|
from .path import BASE_PATH
|
||||||
|
|
||||||
|
|
||||||
class FigureParams(NamedTuple):
|
@define
|
||||||
|
class FigureParams:
|
||||||
"""
|
"""
|
||||||
Attributes:
|
Attributes:
|
||||||
shape: The shape of the figure.
|
shape: The shape of the figure.
|
||||||
@ -41,7 +42,7 @@ class Figure(Enum):
|
|||||||
L: The L figure.
|
L: The L figure.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
I = FigureParams(
|
I = FigureParams( # type: ignore
|
||||||
[
|
[
|
||||||
Vec2(0, 0),
|
Vec2(0, 0),
|
||||||
Vec2(0, -1),
|
Vec2(0, -1),
|
||||||
@ -51,7 +52,7 @@ class Figure(Enum):
|
|||||||
CONFIG.colors.cyan,
|
CONFIG.colors.cyan,
|
||||||
"I.png",
|
"I.png",
|
||||||
)
|
)
|
||||||
O = FigureParams(
|
O = FigureParams( # type: ignore
|
||||||
[
|
[
|
||||||
Vec2(0, 0),
|
Vec2(0, 0),
|
||||||
Vec2(0, -1),
|
Vec2(0, -1),
|
||||||
@ -61,7 +62,7 @@ class Figure(Enum):
|
|||||||
CONFIG.colors.yellow,
|
CONFIG.colors.yellow,
|
||||||
"O.png",
|
"O.png",
|
||||||
)
|
)
|
||||||
T = FigureParams(
|
T = FigureParams( # type: ignore
|
||||||
[
|
[
|
||||||
Vec2(0, 0),
|
Vec2(0, 0),
|
||||||
Vec2(-1, 0),
|
Vec2(-1, 0),
|
||||||
@ -72,7 +73,7 @@ class Figure(Enum):
|
|||||||
"T.png",
|
"T.png",
|
||||||
)
|
)
|
||||||
|
|
||||||
S = FigureParams(
|
S = FigureParams( # type: ignore
|
||||||
[
|
[
|
||||||
Vec2(0, 0),
|
Vec2(0, 0),
|
||||||
Vec2(-1, 0),
|
Vec2(-1, 0),
|
||||||
@ -82,7 +83,7 @@ class Figure(Enum):
|
|||||||
CONFIG.colors.green,
|
CONFIG.colors.green,
|
||||||
"S.png",
|
"S.png",
|
||||||
)
|
)
|
||||||
Z = FigureParams(
|
Z = FigureParams( # type: ignore
|
||||||
[
|
[
|
||||||
Vec2(0, 0),
|
Vec2(0, 0),
|
||||||
Vec2(1, 0),
|
Vec2(1, 0),
|
||||||
@ -92,7 +93,7 @@ class Figure(Enum):
|
|||||||
CONFIG.colors.red,
|
CONFIG.colors.red,
|
||||||
"Z.png",
|
"Z.png",
|
||||||
)
|
)
|
||||||
J = FigureParams(
|
J = FigureParams( # type: ignore
|
||||||
[
|
[
|
||||||
Vec2(0, 0),
|
Vec2(0, 0),
|
||||||
Vec2(0, -1),
|
Vec2(0, -1),
|
||||||
@ -102,7 +103,7 @@ class Figure(Enum):
|
|||||||
CONFIG.colors.blue,
|
CONFIG.colors.blue,
|
||||||
"J.png",
|
"J.png",
|
||||||
)
|
)
|
||||||
L = FigureParams(
|
L = FigureParams( # type: ignore
|
||||||
[
|
[
|
||||||
Vec2(0, 0),
|
Vec2(0, 0),
|
||||||
Vec2(0, -1),
|
Vec2(0, -1),
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user