aboutsummaryrefslogtreecommitdiff
path: root/src/splitscreen_duo/__init__.py
diff options
context:
space:
mode:
authorZoltan Szabatin <[email protected]>2025-03-02 18:50:16 -0800
committerZoltan Szabatin <[email protected]>2025-03-02 18:50:16 -0800
commit1772f26db45108e24f80bd5a26bd3ce353f5b6f1 (patch)
tree25626e13c90b723c2b2f9899fe0be6180cec8cc7 /src/splitscreen_duo/__init__.py
parentfeat: Add snake and benchmark games (diff)
downloadsplitscreen-duo-1772f26db45108e24f80bd5a26bd3ce353f5b6f1.tar.xz
splitscreen-duo-1772f26db45108e24f80bd5a26bd3ce353f5b6f1.zip
feat: Add breakout game
Diffstat (limited to 'src/splitscreen_duo/__init__.py')
-rw-r--r--src/splitscreen_duo/__init__.py23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/splitscreen_duo/__init__.py b/src/splitscreen_duo/__init__.py
index 8233caf..581fe81 100644
--- a/src/splitscreen_duo/__init__.py
+++ b/src/splitscreen_duo/__init__.py
@@ -6,7 +6,7 @@ import logging
import pygame
from .serial import Serial
import json
-from .games import benchmark, snake
+from .games import benchmark, snake, breakout
def main() -> int:
@@ -66,6 +66,18 @@ def main() -> int:
pygame.quit()
return 0
+ elif message.get("value") == Game.BREAKOUT.value:
+ logger.info("received breakout game selection from primary")
+
+ game_result = breakout.main_loop(menu.screen, serial, INSTANCE)
+
+ 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")
@@ -102,6 +114,15 @@ def main() -> int:
pygame.quit()
return 0
+ elif serial_command.get("value") == Game.BREAKOUT.value:
+ logger.info("starting breakout game")
+
+ game_result = breakout.main_loop(menu.screen, serial, INSTANCE)
+
+ if game_result and game_result.get("command") == Command.QUIT.value:
+ pygame.quit()
+
+ return 0
menu.draw_menu()