How atifibrahim7/chess-2d-private works
Project type and purpose
• This is a standalone 2D desktop chess application written in C++ with a clean graphical interface.
• Purpose: Allow two players to play chess on a local machine with full rule support, move validation, game saving/loading, and UI enhancements (highlighting, timers, captured‐piece display).
File structure
• Top‐level directories:
• / – Public headers (board, chessGame, piece, menu, errorReporting, pieceTextures).
• src/ – Implementation (.cpp files) and main entry point (main.cpp).
• resources/Textures/ – All image assets (chess piece images, UI elements).
• CMakeLists.txt – Build configuration.
• Patterns:
• Clear separation of Game Logic (chessGame, board, piece) vs. UI (menu, pieceTextures) vs. Core Application (main.cpp).
• Resource directory for static assets.
Extract key architectural points from README
• Game logic fully encapsulates official chess rules.
• UI layer handles rendering, input, highlighting, timers.
• Game State Manager supports save/load and history tracking.
Main components
a. Application Entry (main.cpp)
b. Game Loop
c. Input Handler
d. UI Renderer
e. Game Logic / Rules Engine
f. Game State Manager
g. Resource Manager (textures)
h. Domain Models (Board, Piece)
i. Menu System
j. Error Reporting
Relationships & Interactions
• main.cpp initializes Resource Manager and Game State Manager, then enters the Game Loop.
• Game Loop cycles: Input Handler → Game Logic → UI Renderer.
• Input Handler reads mouse events and passes commands to Game Logic (e.g., select/move piece).
• Game Logic updates Domain Models (Board, Piece), enforces rules, notifies State Manager (for history, save).
• Menu System hooks into Input Handler and UI Renderer to provide start/load/save functionality.
• Error Reporting monitors invalid moves or runtime issues and surfaces alerts via UI Renderer.
Architectural patterns & design principles
• MVC‐like separation:
• Model – Domain Models + Game State Manager
• View – UI Renderer + Resource Manager
• Controller – Input Handler + Menu System
• Single Responsibility: each module (board logic, piece behavior, rendering, input) has a focused role.
• Event‐driven loop: central game loop dispatches input and orchestrates rendering/updates.
• Clear labels: e.g., “Game Logic Engine”, “Board Model”, “Piece Model”, “Texture Manager”.