mirror of
https://github.com/kristoferssolo/Tetris.git
synced 2025-10-21 20:00:35 +00:00
feat(utils): add game configs/settings
This commit is contained in:
parent
7bc10c62d0
commit
d299934e7c
@ -1,6 +1,41 @@
|
|||||||
|
from typing import NamedTuple
|
||||||
|
|
||||||
from attr import define
|
from attr import define
|
||||||
|
|
||||||
|
|
||||||
|
class Size(NamedTuple):
|
||||||
|
width: int
|
||||||
|
height: int
|
||||||
|
|
||||||
|
|
||||||
|
@define
|
||||||
|
class Game:
|
||||||
|
columns: int = 10
|
||||||
|
rows: int = 20
|
||||||
|
cell_size: int = 40
|
||||||
|
size: Size = Size(columns * cell_size, rows * cell_size)
|
||||||
|
|
||||||
|
|
||||||
|
@define
|
||||||
|
class SideBar:
|
||||||
|
size: Size = Size(200, Game().size.height)
|
||||||
|
preview_height_fraction: float = 0.7
|
||||||
|
score_height_fraction: float = 1 - preview_height_fraction
|
||||||
|
|
||||||
|
|
||||||
|
@define
|
||||||
|
class Window:
|
||||||
|
padding: int = 20
|
||||||
|
size: Size = Size(
|
||||||
|
Game().size.width + SideBar().size.width + padding * 3,
|
||||||
|
Game().size.height + padding * 2,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@define
|
@define
|
||||||
class Config:
|
class Config:
|
||||||
log_level = "warning"
|
log_level: str = "warning"
|
||||||
|
|
||||||
|
game: Game = Game()
|
||||||
|
sidebar: SideBar = SideBar()
|
||||||
|
window: Window = Window()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user