refactor(game)

This commit is contained in:
Kristofers Solo 2024-01-06 23:18:10 +02:00
parent 080ba1b9cb
commit c8859bc571
4 changed files with 13 additions and 8 deletions

View File

@ -46,15 +46,18 @@ class Main(BaseScreen, SceenElement, TextScreen):
def run(self) -> None:
while True:
if not self.game:
self.draw()
self.run_game_loop()
self.handle_events()
def run_game_loop(self) -> None:
if not self.game:
self.draw()
if self.game:
self.game.run()
self.handle_events()
self.update()
if self.game:
self.game.run()
self.update()
def exit(self) -> None:
"""Exit the game."""

View File

@ -341,7 +341,8 @@ class Tetris(BaseScreen):
def _play_landing_sound(self) -> None:
"""Play the landing sound effect."""
self.landing_sound.play()
if self.game_mode is GameMode.PLAYER:
self.landing_sound.play()
def _update_display_surface(self) -> None:
"""Update the display surface."""

View File

@ -17,4 +17,5 @@ __all__ = [
"Rotation",
"GameMode",
"Weights",
"BestMove",
]

View File

@ -15,4 +15,4 @@ class Size(NamedTuple):
class BestMove(NamedTuple):
rotation: int
direction: Direction
x: int