aboutsummaryrefslogtreecommitdiff
path: root/src/splitscreen_duo/__init__.py
diff options
context:
space:
mode:
authorZoltan Szabatin <[email protected]>2025-03-02 19:56:28 -0800
committerZoltan Szabatin <[email protected]>2025-03-02 19:56:28 -0800
commit4ee5ce27a8309be7989e2126f39f9411c1178da2 (patch)
tree7c3cd8874065ad6ed236c6f1385e7300e5074a69 /src/splitscreen_duo/__init__.py
parentrefactor: Create base game class for games (diff)
downloadsplitscreen-duo-4ee5ce27a8309be7989e2126f39f9411c1178da2.tar.xz
splitscreen-duo-4ee5ce27a8309be7989e2126f39f9411c1178da2.zip
feat: Add pong game
Diffstat (limited to 'src/splitscreen_duo/__init__.py')
-rw-r--r--src/splitscreen_duo/__init__.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/splitscreen_duo/__init__.py b/src/splitscreen_duo/__init__.py
index 9fef2eb..9689db4 100644
--- a/src/splitscreen_duo/__init__.py
+++ b/src/splitscreen_duo/__init__.py
@@ -9,6 +9,7 @@ import json
from .games import benchmark
from .games.snake import Snake
from .games.breakout import Breakout
+from .games.pong import Pong
def main() -> int:
@@ -82,6 +83,19 @@ def main() -> int:
pygame.quit()
return 0
+ elif message.get("value") == Game.PONG.value:
+ logger.info("received pong game selection from primary")
+
+ pong_game = Pong(menu.screen, serial, INSTANCE)
+ game_result = pong_game.main_loop()
+
+ if (
+ game_result
+ and game_result.get("command") == Command.QUIT.value
+ ):
+ pygame.quit()
+
+ return 0
except json.JSONDecodeError:
logger.error("failed to decode serial message")
@@ -129,6 +143,16 @@ def main() -> int:
pygame.quit()
return 0
+ elif serial_command.get("value") == Game.PONG.value:
+ logger.info("starting pong game")
+
+ pong_game = Pong(menu.screen, serial, INSTANCE)
+ game_result = pong_game.main_loop()
+
+ if game_result and game_result.get("command") == Command.QUIT.value:
+ pygame.quit()
+
+ return 0
menu.draw_menu()