How ordinary56/infinitehorde works
1. Project shape and purpose
- *Infinite Horde* is a C++ game project organized around a small engine layer plus game-specific content.
- The repository is split into reusable core systems, entity/gameplay code, scene orchestration, UI, and platform-specific backends.
2. Top-level runtime flow
- main.cpp is the entry point and likely bootstraps the core game object.
- The central runtime path is: platform setup → input/input polling → scene update → world/entity simulation → rendering.
- core/game.h and core/gameWorld.h are the main coordination points for the game loop and shared simulation state.
3. Platform boundary
- include/platform/platform.h defines an abstraction over the host environment.
- raylibPlatform and consolePlatform indicate two execution modes:
- a graphical mode using raylib
- a console-oriented mode for simpler output or debugging
- This boundary isolates window/input lifecycle and platform-specific startup/shutdown from gameplay code.
4. Rendering boundary
- core/renderer/renderer.h is the renderer interface.
- raylibRenderer is the graphical backend, while consoleRenderer is a non-graphical backend.
- Rendering is likely driven from scenes and/or the game world, with sprites and UI elements drawn through this abstraction rather than directly from gameplay classes.
5. Input and camera
- core/input/inputSystem.h defines input handling; raylibInputSystem connects that interface to raylib.
- core/camera/cameraController.h and cameraData.h manage view position/zoom/targeting for gameplay.
- This suggests input feeds both player control and camera behavior, with the camera remaining separate from entity logic.
6. Scene architecture
- scene/scene.h is the scene contract, and sceneManager.h owns the active scene.
- There are at least two scenes:
- mainMenuScene
- gameplayScene
- Scene transitions are the main boundary between menu flow and in-game simulation, which is a clean place to diagram top-level application states.
7. Gameplay/world layer
- entity/entity.h is the base type for in-world actors.
- Concrete gameplay types include player, enemy, projectile, and weapon.
- Manager classes such as enemyManager and projectileManager suggest centralized spawning, lifetime management, and updates for those object groups.
- gameWorld likely aggregates these systems and exposes the shared state used by the gameplay scene.
8. Interaction and decoupling
- core/events/eventManager.hpp and handler.h show an event system for loose coupling between subsystems.
- This is likely used for game events such as hits, deaths, UI actions, or scene changes without hard wiring all components together.
- core/timer/timer.h provides time measurement, frame timing, or cooldown behavior, which is essential in a real-time action game.
9. UI subsystem
- ui/uiElement.h, ui/uiContainer.h, and ui/uiButton.h define a small retained UI hierarchy.
- ui/builders/uiButtonBuilder.h suggests a construction helper for configurable buttons.
- The UI layer is separate from gameplay entities, which makes menu screens and overlays easier to manage inside scenes.
10. Sprites and assets
- sprite/spriteManager.h and sprite_entry.h indicate a resource registry for sprite assets.
- This sits between raw asset loading and entity/UI drawing, so entities probably reference sprite entries rather than owning graphics data directly.
11. Math and shared utilities
- core/math/vec2.h and rect.h provide the basic 2D types used across movement, collision, UI layout, and camera logic.
- helpers/helpers.h and helpers/utils.hpp contain shared utility code that is reused across systems but does not belong to a single subsystem.
12. Tooling, tests, and diagnostics
- The project uses CMake with Linux and Windows toolchain files, so the architecture is intended to be cross-platform.
- tests/main_test.cpp with gtest_lite provides a lightweight test harness.
- memtrace and raylib.supp indicate memory/debug tracing support, which is useful for catching leaks or allocation issues in a game loop.
13. How to draw the architecture
- A good diagram would place main at the top feeding into Game, with Platform, Renderer, and InputSystem as replaceable backends.
- Below that, show SceneManager choosing between MainMenuScene and GameplayScene.
- Inside gameplay, show GameWorld coordinating Player, Enemies, Projectiles, Weapons, Camera, UI, Sprites, and Events.
- The clearest boundaries are: platform/backend, scene/state, world/entity simulation, and UI/resource management.
Main entry points: gameWorld.h Game World · gameplayScene.h Gameplay · game.h Game · renderer.h Renderer
Components 23
Runtime flow
Entry point, core loop, and scene orchestration.
- Main · Program entry point.
src/main.cpp - Game · Owns the top-level application flow and runtime wiring.
include/core/game.h - Scene Manager · Selects and switches the active scene.
include/scene/sceneManager.h
Backends
Replaceable platform, input, and rendering implementations.
- Platform · Abstracts OS/window lifecycle and startup/shutdown.
include/platform/platform.h - Renderer · Abstract rendering interface used by scenes and gameplay.
include/core/renderer/renderer.h - Input · Abstract input polling and event translation.
include/core/input/inputSystem.h - Raylib Plat · Raylib host implementation.
include/platform/raylibPlatform.h - Console Plat · Console-oriented host implementation.
include/platform/consolePlatform.h - Raylib Render · Raylib rendering implementation.
include/core/renderer/raylibRenderer.h - Console Render · Non-graphical rendering implementation.
include/core/renderer/consoleRenderer.h - Raylib Input · Raylib-backed input implementation.
include/core/input/raylibInputSystem.h
Gameplay
World simulation and entity systems.
- Game World · Shared world state for gameplay systems.
include/core/gameWorld.h - Player · Player-controlled actor.
include/entity/player.h - Enemies · Spawns and updates enemies.
include/entity/enemyManager.h - Projectiles · Creates and manages projectiles.
include/entity/projectileManager.h
Presentation
Scenes, UI, and sprite resources.
- Main Menu · Menu scene for top-level navigation.
include/scene/mainMenuScene.h - Gameplay · In-game scene that drives simulation and rendering.
include/scene/gameplayScene.h - Sprites · Central sprite/resource lookup.
include/sprite/spriteManager.h - UI · Retained UI hierarchy for menus and overlays.
include/ui/uiElement.h
Shared core
Cross-cutting math, timing, and events.
- Camera · Controls viewport position and zoom.
include/core/camera/cameraController.h - Events · Loose coupling between gameplay subsystems.
include/core/events/eventManager.hpp - Math · Shared 2D primitives for movement, bounds, and layout.
include/core/math/vec2.h - Timer · Time measurement and cooldown support.
include/core/timer/timer.h
Connections 26
- Main → Game: boots · Program startup enters the main game coordinator.
- Game → Platform: uses · Game depends on the platform abstraction.
- Game → Renderer: uses · Game depends on the rendering abstraction.
- Game → Input: uses · Game depends on abstract input handling.
- Game → Scene Manager: owns · Game delegates flow to the scene manager.
- Platform → Raylib Plat: impl · Graphical host backend.
- Platform → Console Plat: impl · Console host backend.
- Renderer → Raylib Render: impl · Raylib drawing backend.
- Renderer → Console Render: impl · Console drawing backend.
- Input → Raylib Input: impl · Raylib input backend.
- Scene Manager → Main Menu: activates · Menu scene is one top-level state.
- Scene Manager → Gameplay: activates · Gameplay scene is the in-game state.
- Gameplay → Game World: drives · Gameplay scene updates the simulation world.
- Game World → Player: contains · Player is part of the world state.
- Game World → Enemies: contains · Enemy management lives inside the world.
- Game World → Projectiles: contains · Projectile lifecycle is managed centrally.
- Game World → Camera: updates · World feeds camera behavior and view state.
- Game World → Events: publishes · World events decouple gameplay systems.
- Game World → Sprites: references · World and entities use shared sprite assets.
- Gameplay → UI: lays out · Gameplay and menus can present UI overlays.
- Gameplay → Renderer: draws via · Scene rendering goes through the renderer interface.
- Gameplay → Input: reads · Scene consumes input through the input abstraction.
- Gameplay → Math: uses · Scene logic relies on shared geometry types.
- Game World → Math: uses · Simulation relies on shared geometry types.
- Game World → Timer: uses · Timing supports updates, cooldowns, and frame control.
- UI → Sprites: uses · UI widgets can share the sprite registry.