How shingzhanho/engg1330-project-24fall works
• The game’s core logic, contained within the speed_slide package, which includes game scenes, constants, I/O methods, and the game board logic.
• A text-based user interface (TUI) framework, in the tui package, that provides controls (like text labels, borders, formatted text) and scene management.
Main Components
a. Entry Point (main.py):
– This is the launching script that initializes the game.
b. Core Game Module (speed_slide):
– __game_consts.py: Contains runtime-configurable constants (screen dimensions, animation timing, debug flag, etc.).
– io.py: Manages input and simple sound (beep) functionality.
– game_scenes: A directory of modules implementing individual game scenes such as title, main game, help, about, game over, etc.
• Each scene (e.g., TitleScene, MainGameMenuScene, MainGameScene) is implemented as a subclass of the Scene class from the TUI framework.
• A specialised folder within game_scenes (customised_controls) contains custom UI components like the ScoreLabel.
– The game board logic (embedded within MainGameScene and the internal __GameBoard class) that manages board state, moves, and win-checking.
c. TUI Framework (tui):
– Contains core modules for UI rendering and interactions:
• Base scene and screen management (scene.py, screen.py).
• Controls and layout elements (controls folder, with components like control.py, border_tools, dialogue_window, and rich_format_text).
• Utilities for text formatting and transitions.
Mapping Relationships and Interactions
• The entry point (main.py) invokes the main() method provided in speed_slide/__init__.py.
• The speed_slide module depends on the tui framework to render its game scenes.
• Game scenes (title, main menu, game over, etc.) extend from tui.scene.Scene and thus inherit behavior defined in the TUI module.
• The __GameBoard (in MainGameScene) encapsulates board logic and interacts with player input (via io.py.safe_input) and uses internal methods (like slide() and find_adjacent()) to update the game state.
• Commands passed (e.g., debug commands like /pass-a, /pass-b, /fail) are handled in-game to change the flow or advance to different scenes.
• The tui module’s controls (e.g., ScoreLabel, TxtLabel) are used by scenes to render dynamic content (score display, messages).
Architectural Patterns and Design Principles
• Modularity: Separate packages for core game logic (speed_slide) and UI rendering (tui).
• Layered approach: The game’s business logic (board manipulation, scene transitions) is separated from its presentation layer (TUI controls, ASCII animations).
• Extensibility: The use of a TUI framework that provides a base Scene class enables the addition of new scenes or controls without altering the core logic significantly.
• Commandline Configuration: Command-line arguments (e.g., --debug, --graphics-mode) adjust runtime behaviour, hinting at runtime configurability.
Final Checklist for the Principal Software Engineer
– Clearly label every component (e.g., “Main Entry Point (main.py)”, “Game Scenes”, “Game Board Logic (__GameBoard)”, “TUI Framework”).
– Include annotations for command-line configuration and debug mode to illustrate how alternate behaviors are triggered at runtime.