How vietthang5605/gameproject works
Main Components
• Game Core – This is where the primary logic resides (e.g., Game.cpp, main.cpp). It represents the game loop and overall coordination.
• Entities – Components such as Player, Bullet, Polygon, PlayerArrow, Button, and Entity are declared in headers and implemented in src. They form the building blocks for in-game objects.
• Physics & Collision – The Maths.cpp and associated headers (like Maths.h, Polygon.h) encapsulate the logic for movement and collision handling using techniques such as SAT.
• AI Module – Embedded in the game logic (likely within the Game or Player classes), this module uses Minimax, Alpha-Beta pruning, and Heuristic evaluations to control AI players.
• Resource Management – This encompasses loading and managing external resources like images, audio, fonts (from the “res” directory). Resources are used in rendering the visual components and playing sounds.
• SDL2 Integration – SDL2 components (headers under include/SDL2, the linked libraries under lib, and the corresponding pkgconfig files) form the backbone for handling graphics, events, audio, input, and more.
• Platform/Build Layer – There’s support for both desktop and web targets. On the desktop, compilation is via g++ (see the provided command) while for the web the project uses Emscripten, with an output of .html, .js, .wasm, and associated files under the “web” directory.
• Build & Deployment – The Makefile, various configuration files (e.g., cmake files in lib/cmake) and compile instructions (emccCompile.txt) form the build system that orchestrates how source files and libraries are combined.
• Game Core to the Physics & Collision module (Maths and Polygon interactions) showing that entity positions and collision checks are performed each frame.
• AI module feeding decisions into Player/Entity objects – showing a directional flow from the AI logic to modify game state.
• Integration with SDL2 by showing that multiple subsystems (Rendering, Input, Audio) are wrappers around SDL2 libraries.
• Resource Management should be shown as a subsystem that feeds data (images, sounds, fonts) into both the Audio and Rendering subsystems.
• Incorporate a branch that distinguishes the platform/build layer for Desktop versus Web:
– For Desktop, show that the classical C++ build (using g++ and linking against SDL2 libraries) leads to the main.exe.
– For Web, indicate that Emscripten compiles the same source into WebAssembly (with supporting HTML/JavaScript files), making use of preloaded “res” files.
Architectural Patterns and Design Principles
• Modular design – Each game component (entity, physics, AI, etc.) is organized into separate files/modules.
• Clear separation of concerns – The project distinguishes between game logic, rendering, input handling, and system interfacing.
• Use of Object-Oriented Programming – Classes such as Player, Button, etc., encapsulate their own behavior and interact through well-defined interfaces.
• Layered architecture – There is a clear layering from low-level SDL2 operations and platform concerns to higher-level game logic and AI.