diff options
| author | Zoltan Szabatin <[email protected]> | 2025-03-02 19:01:12 -0800 |
|---|---|---|
| committer | Zoltan Szabatin <[email protected]> | 2025-03-02 19:01:12 -0800 |
| commit | 3ba60ffec522cd35c137573f666aaea3ee899c7c (patch) | |
| tree | c7e44a62f4dd701669aee1f318ed17aff28ae858 /src/splitscreen_duo/__init__.py | |
| parent | feat: Add breakout game (diff) | |
| download | splitscreen-duo-3ba60ffec522cd35c137573f666aaea3ee899c7c.tar.xz splitscreen-duo-3ba60ffec522cd35c137573f666aaea3ee899c7c.zip | |
refactor: Create base game class for games
Diffstat (limited to 'src/splitscreen_duo/__init__.py')
| -rw-r--r-- | src/splitscreen_duo/__init__.py | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/splitscreen_duo/__init__.py b/src/splitscreen_duo/__init__.py index 581fe81..9fef2eb 100644 --- a/src/splitscreen_duo/__init__.py +++ b/src/splitscreen_duo/__init__.py @@ -6,7 +6,9 @@ import logging import pygame from .serial import Serial import json -from .games import benchmark, snake, breakout +from .games import benchmark +from .games.snake import Snake +from .games.breakout import Breakout def main() -> int: @@ -57,7 +59,8 @@ def main() -> int: elif message.get("value") == Game.SNAKE.value: logger.info("received snake game selection from primary") - game_result = snake.main_loop(menu.screen, serial, INSTANCE) + snake_game = Snake(menu.screen, serial, INSTANCE) + game_result = snake_game.main_loop() if ( game_result @@ -69,7 +72,8 @@ def main() -> int: elif message.get("value") == Game.BREAKOUT.value: logger.info("received breakout game selection from primary") - game_result = breakout.main_loop(menu.screen, serial, INSTANCE) + breakout_game = Breakout(menu.screen, serial, INSTANCE) + game_result = breakout_game.main_loop() if ( game_result @@ -108,7 +112,8 @@ def main() -> int: elif serial_command.get("value") == Game.SNAKE.value: logger.info("starting snake game") - game_result = snake.main_loop(menu.screen, serial, INSTANCE) + snake_game = Snake(menu.screen, serial, INSTANCE) + game_result = snake_game.main_loop() if game_result and game_result.get("command") == Command.QUIT.value: pygame.quit() @@ -117,7 +122,8 @@ def main() -> int: elif serial_command.get("value") == Game.BREAKOUT.value: logger.info("starting breakout game") - game_result = breakout.main_loop(menu.screen, serial, INSTANCE) + breakout_game = Breakout(menu.screen, serial, INSTANCE) + game_result = breakout_game.main_loop() if game_result and game_result.get("command") == Command.QUIT.value: pygame.quit() |