This commit is contained in:
Kristofers Solo 2024-01-08 18:46:23 +02:00
parent e6a2b474e6
commit 12776ee181
14 changed files with 23 additions and 78 deletions

View File

@ -1,8 +1,5 @@
from abc import ABC, ABCMeta, abstractmethod
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from typing import Any
from typing import Any
class BaseScreen(ABC, metaclass=ABCMeta):

View File

@ -1,8 +1,5 @@
from abc import ABC, ABCMeta, abstractmethod
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from typing import Any, Callable, Optional
from typing import Any, Callable, Optional
import pygame

View File

@ -1,4 +1,4 @@
from typing import TYPE_CHECKING
from typing import Any, Callable, Optional
import pygame
from utils import CONFIG
@ -6,9 +6,6 @@ from utils import CONFIG
from .base import BaseScreen, SceenElement, TextScreen
from .base_button import BaseButton
if TYPE_CHECKING:
from typing import Any, Callable, Optional
class Button(BaseButton, BaseScreen, SceenElement, TextScreen):
def __init__(self, text: str, action: Optional[Callable[[], Optional[Any]]]) -> None:

View File

@ -1,18 +1,13 @@
from typing import TYPE_CHECKING
from typing import Any
import pygame
from utils import CONFIG, GameMode
from utils import CONFIG, Figure, GameMode
from .base import BaseScreen
from .preview import Preview
from .score import Score
from .tetris import Tetris
if TYPE_CHECKING:
from typing import Any
from utils import Figure
class Game(BaseScreen):
"""
@ -56,14 +51,12 @@ class Game(BaseScreen):
def run(self) -> None:
"""Run a single iteration of the game loop."""
self.draw()
self.tetris.run()
self.score.run()
self.preview.update(self.next_figure)
self.preview.run()
self.draw()
self.clock.tick(CONFIG.game.fps)
def mute(self) -> None:

View File

@ -1,19 +1,14 @@
import sys
from typing import TYPE_CHECKING
from typing import Optional
import pygame
from loguru import logger
from utils import CONFIG, read_settings
from utils import CONFIG, GameMode, read_settings
from .base import BaseScreen, SceenElement, TextScreen
from .button import Button
from .game import Game
if TYPE_CHECKING:
from typing import Optional
from utils import GameMode
class Main(BaseScreen, SceenElement, TextScreen):
"""

View File

@ -1,13 +1,8 @@
from typing import TYPE_CHECKING
import pygame
from utils import CONFIG
from utils import CONFIG, Figure
from .base import BaseScreen, SceenElement
if TYPE_CHECKING:
from utils import Figure
class Preview(BaseScreen, SceenElement):
"""

View File

@ -1,20 +1,15 @@
from typing import TYPE_CHECKING
from typing import Any, Callable, Optional
import numpy as np
import pygame
from loguru import logger
from utils import CONFIG, Direction, Figure, GameMode, Rotation
from game.sprites import Tetromino
from game.sprites import Block, Tetromino
from game.timer import Timer, Timers
from .base import BaseScreen
if TYPE_CHECKING:
from typing import Any, Callable, Optional
from game.sprites import Block
class Tetris(BaseScreen):
"""

View File

@ -1,13 +1,9 @@
from typing import TYPE_CHECKING
from typing import Any, Optional
import numpy as np
import pygame
from utils import CONFIG, Rotation
if TYPE_CHECKING:
from typing import Any, Optional
import numpy as np
class Block(pygame.sprite.Sprite):
"""

View File

@ -1,14 +1,10 @@
from typing import TYPE_CHECKING
from typing import Any, Callable, Optional
import numpy as np
import pygame
from utils import CONFIG, Direction, Figure, Rotation
if TYPE_CHECKING:
from typing import Any, Callable, Optional
import numpy as np
from .block import Block
from .block import Block
class Tetromino:

View File

@ -1,11 +1,8 @@
from typing import TYPE_CHECKING
from typing import Any, Callable, NamedTuple, Optional
import pygame
from attrs import define, field
if TYPE_CHECKING:
from typing import Any, Callable, NamedTuple, Optional
@define
class Timer:

View File

@ -1,6 +1,7 @@
from typing import TYPE_CHECKING
from pathlib import Path
from attr import define
from pygame import Vector2 as Vec2
from .colors import COLOR_DICT, TokyoNightNight
from .colors.tokyonight.base import Color
@ -8,12 +9,6 @@ from .path import BASE_PATH
from .settings import read_settings
from .tuples import Size
if TYPE_CHECKING:
from pathlib import Path
from pygame import Vector2 as Vec2
PADDING = 20

View File

@ -1,15 +1,13 @@
import random
from enum import Enum
from typing import TYPE_CHECKING, NamedTuple
from typing import NamedTuple
import pygame
from pygame import Vector2 as Vec2
from .colors import TokyoNightNight
from .path import BASE_PATH
if TYPE_CHECKING:
from pygame import Vector2 as Vec2
class FigureConfig(NamedTuple):
"""

View File

@ -1,14 +1,11 @@
from typing import TYPE_CHECKING
from pathlib import Path
from typing import Any
import toml
from loguru import logger
from .path import BASE_PATH
if TYPE_CHECKING:
from pathlib import Path
from typing import Any
def save_settings(settings: dict[str, Any], file_path: Path) -> None:
"""

View File

@ -1,7 +1,4 @@
from typing import TYPE_CHECKING, NamedTuple
if TYPE_CHECKING:
from typing import Union
from typing import NamedTuple, Union
class Size(NamedTuple):