How btlcode4t/game works
Project type and purpose
• This is a native C++ 2D side-scroller game (“Khủng long chạy”) built with CMake and organized into a lightweight custom game engine (Core), the gameplay logic (GamePlay), utilities (Utils), and external assets (images, sounds, data files).
Top-level file-structure analysis
• CMakeLists.txt / .github/workflows/ci.yml: build system and CI.
• / and src/: engine modules under Core (Audio, GameLoop, Input, Renderer, ResourceManager), gameplay subsystems under GamePlay (Avatar, Entity, Gun, Map, Physics, UI), plus common Utils.
• assets/: all runtime media (Images, Sounds, music).
• data/: persistent files (score, settings, JSON).
• Docs/: design mind-maps.
Key architectural patterns and modules
• Layered / modular design
• Core layer (engine services)
• Gameplay layer (domain logic)
• Asset & Data layer (resources + persistence)
• GameLoop drives each tick: polls Input, updates Physics & game state, triggers AI/Entity logic, then hands off to Renderer & Audio.
• ResourceManager centralizes loading of textures, sounds and hands handles to subsystems.
• SettingsManager & Scores I/O use plain-text/JSON in data/.
Components
a. Core Engine
• GameLoop
• InputManager
• Renderer
• AudioManager (MusicManager)
• ResourceManager
b. Gameplay Subsystems
• PhysicsSystem
• Entity / Avatar / Dinosaur / Gun modules
• MapManager
• UI (Animation, Scores, StateUI)
c. Data & Persistence
• SettingsManager (reads/writes SettingsManager.txt, data.json)
• ScoresManager (reads/writes Scores.txt)
d. Assets
• Images, Sounds, Music folders
e. Build & CI (optional)
• CMake (build graph)
• GitHub Actions (ci.yml)
Relationships and data‐flow
• GameLoop → InputManager : “poll events”
• GameLoop → PhysicsSystem : “apply forces, collision”
• GameLoop → Entity & Gameplay modules : “update state”
• GameLoop → UI : “render UI overlays”
• ResourceManager → Renderer/AudioManager : “provide loaded assets”
• InputManager → Gameplay : “user commands → movement/shoot”
• SettingsManager/ScoresManager ↔ GameLoop : “load at startup, save on exit”
Important architectural/design principles
• Single-responsibility modules (each folder is one subsystem)
• Decoupling via ResourceManager: no subsystem loads raw files directly
• Event-driven loop: Core.GameLoop is the heartbeat
• Layered calls: Core services → GamePlay → UI → Renderer/Audio
Final checklist
• All components are clearly labeled.
• Layers or swim-lanes reflect architectural separation.