How bsrodrigue/rapid_shooter works
Project type and purpose
• This is a native C++ game/application with an integrated level-editor and entity-editor, built via CMake.
• It uses raylib (via rlImGui), ImGui for UI, cJSON for config loading, and a custom asset/code-generation pipeline.
Main architectural layers
A. Toolchain & Build
– CMakeLists.txt & build/ directory
– Codegen scripts (scripts/codegen/*.py)
– External libraries (external/imgui, external/rlImGui)
B. Asset & Content Pipeline
– Asset folders (assets/shaders, assets/textures)
– Configs (configs/entities/entities.json)
– scripts/codegen converting JSON + shaders + textures → C++ loader code
C. Engine & Runtime
– Core game loop (src/main.cc → game.cc)
– Subsystems:
· Entity management (entities.cc/h)
· Input & UI (rlImGui, editor UI in level_editor.cc/h)
· Physics/collision (collision.cc/h)
· Game logic (player.cc, enemy.cc, projectiles.cc, item.cc, etc.)
· Persistence (save.cc/h, json.cc/h)
D. Tool/UI Mode
– Level editor (level_editor.cc/h + level_editor_utils)
– Entity editor (editor_entities.h + UI panels via ImGui)
Relationships & data flows
• Build System → links External Libs + src + generated code → produces “autohacka” binary
• At runtime:
1. main() initializes subsystems (graphics, input, audio if any, config loader)
2. Config Loader parses JSON (via cJSON) → populates Entity definitions & level data
3. Asset Manager loads textures/shaders from disk → creates GPU resources
4. Game Loop iterates:
a. Input System captures user/keyboard events → forwards to Game Logic & Editor UI
b. Physics System updates collision/world state
c. Entity System updates all entities (player, enemies, items, projectiles)
e. UI System (ImGui) draws overlays & editor panels
5. Save System serializes game state back to JSON when requested
Architectural patterns & design principles
• Modular Subsystems: each responsibility isolated (Rendering, Physics, Input, UI, Persistence)
• Data-Driven Entities: definitions in JSON generate C++ code allowing hot edits
• Codegen Pipeline: scripts/codegen to automate repetitive loader/serializer code
• Editor integration: same engine core supports both gameplay and editing modes
Elements
– Build System (CMake + codegen scripts + external libs)
– Config Service (JSON loader via cJSON)
– Asset Manager (textures, shaders)
– Subsystems: Input, Physics, Entity Manager, Renderer, UI, Save/Load
– Game Loop coordinator
– Level Editor & Entity Editor modules
– Show build-time flow: codegen → compile → binary
– Show runtime data-flow: Input → Game Loop → Subsystems → Renderer/UI → Frame output
– Config & Assets → loaded into memory → used by Subsystems