mirror of
https://github.com/kristoferssolo/Tetris.git
synced 2025-10-21 20:00:35 +00:00
refactor(game)
This commit is contained in:
parent
080ba1b9cb
commit
c8859bc571
@ -46,15 +46,18 @@ class Main(BaseScreen, SceenElement, TextScreen):
|
|||||||
|
|
||||||
def run(self) -> None:
|
def run(self) -> None:
|
||||||
while True:
|
while True:
|
||||||
if not self.game:
|
self.run_game_loop()
|
||||||
self.draw()
|
|
||||||
|
|
||||||
self.handle_events()
|
def run_game_loop(self) -> None:
|
||||||
|
if not self.game:
|
||||||
|
self.draw()
|
||||||
|
|
||||||
if self.game:
|
self.handle_events()
|
||||||
self.game.run()
|
|
||||||
|
|
||||||
self.update()
|
if self.game:
|
||||||
|
self.game.run()
|
||||||
|
|
||||||
|
self.update()
|
||||||
|
|
||||||
def exit(self) -> None:
|
def exit(self) -> None:
|
||||||
"""Exit the game."""
|
"""Exit the game."""
|
||||||
|
|||||||
@ -341,7 +341,8 @@ class Tetris(BaseScreen):
|
|||||||
|
|
||||||
def _play_landing_sound(self) -> None:
|
def _play_landing_sound(self) -> None:
|
||||||
"""Play the landing sound effect."""
|
"""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:
|
def _update_display_surface(self) -> None:
|
||||||
"""Update the display surface."""
|
"""Update the display surface."""
|
||||||
|
|||||||
@ -17,4 +17,5 @@ __all__ = [
|
|||||||
"Rotation",
|
"Rotation",
|
||||||
"GameMode",
|
"GameMode",
|
||||||
"Weights",
|
"Weights",
|
||||||
|
"BestMove",
|
||||||
]
|
]
|
||||||
|
|||||||
@ -15,4 +15,4 @@ class Size(NamedTuple):
|
|||||||
|
|
||||||
class BestMove(NamedTuple):
|
class BestMove(NamedTuple):
|
||||||
rotation: int
|
rotation: int
|
||||||
direction: Direction
|
x: int
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user