How shingzhanho/engg1340-project-25spring works
Project Type & Purpose
• SHOOT! is a C++ console-based shooting game with:
• Core game logic (entities, arena, event handling)
• UI layer (FTXUI-based rendering)
• Utility modules (logging, file I/O, map parsing)
• Multithreading for game ticks and logging (pthread)
High-Level Components
A. Executable (“main”)
B. Core Layer (namespace core)
1. Game
2. Arena & ArenaReader
3. Entity hierarchy (Entity ← Player, Monster, Bullet, Collectible, etc.)
4. EventHandler hierarchy (EventHandler ← TickRefreshHandler, InputHandler, SpawnHandler, etc.)
5. GameOptions, Leaderboard
C. UI Layer (namespace ui + FTXUI)
1. game_ui_renderer, render_option, common UI widgets
2. game_level_ui, game_score_ui, leaderboard_ui
D. Util Layer (namespace util)
1. log (logger), file utilities
E. Resources
1. Files (res/default_maps & res/sample_maps)
2. Leaderboard storage files
F. External Services & Libraries
1. FTXUI (console GUI)
2. pthread (threading)
Namespaces & Class Dependencies
• Inside core:
• ArenaReader has a dependency on file I/O to build an Arena.
• Game composes Arena and one or more EventHandlers, and depends on GameOptions and Leaderboard.
• In ui:
• UI screens (game_level_ui, game_score_ui, leaderboard_ui) depend on Game and GameUIRenderer.
• In util:
• Log provides logging services to Core (Arena, Game, EventHandlers) and UI.
• File operations (map loading, leaderboard saving) depend on util::log and standard I/O.
Relationships & Data Flows
• Main → instantiates Game
• Game → initializes Arena, EventHandlers, UI screens
• EventHandlers → invoke methods on Arena (spawn, move, collision)
• Arena → updates Entities and notifies EventHandlers
• UI → polls Game state each frame (via Game and Arena) and renders via FTXUI
• Util::log ← subscribed by Core/UI to write logs
• Reader → reads map file → provides initial Arena state
• Leaderboard ↔ file system for score persistence
Architectural Patterns & Design Principles
• Namespace modularity: core vs ui vs util
• Abstract base classes + inheritance for Entities and EventHandlers (polymorphism)
• Single Responsibility:
• Arena manages state
• EventHandler executes actions
• Game orchestrates lifecycle
• UI renders and handles input
• Dependency injection: GameOptions and map path passed into Game/ArenaReader
• Thread safety: Arena uses mutexes for multithreaded tick refresh and logging
Mandatory Elements
• Clear labels for each component and namespace