How ptidejteam/ecs-survivors works
Project type and purpose
• Project type: A C++ desktop (and optionally WebAssembly) game application demonstrating an Entity Component System (ECS) architecture.
• Purpose: Showcase how to build a survivor-like 2D game with ECS using the Flecs framework and Raylib for rendering, input, audio, and window management.
File structure
• Top-level build and config:
• CMakeLists.txt, CMakeSettings.json – root build definitions
• .gitignore, .gitattributes, .clang-format – tooling and style
• README.md, LICENSE – project metadata
• app/ – application entry point (main.cpp)
• src/ – core game code, subdivided by “modules” following ECS modules:
• engine/ (core, input, physics, rendering)
• gameplay/
• player/
• tilemap/
• ai/
• debug/
• / – public headers (raygui wrapper)
• external/ – external dependencies (tmxlite for TMX map parsing)
• resources/ – assets (styles, tiled projects, tilemaps, tilesets)
Review README for insights
• Confirms use of Flecs (ECS) and Raylib (rendering & input).
• Mentions separate build instructions for desktop & WebAssembly.
• Points to blog posts describing pipeline and systems.
Main components
A. Application Layer
• “ECS_Survivors” executable (app/main.cpp) – initializes Raylib window & Flecs world, loads resources, configures system pipelines, enters game loop.
B. ECS Framework
• Flecs World – central registry for entities & components.
• Systems – grouped into modules (engine.core, engine.input, engine.physics, engine.rendering, gameplay, player, tilemap, ai, debug).
C. External Libraries
• Raylib – window/context creation, input polling, 2D drawing, audio playback.
• tmxlite – TMX map parsing for tilemap system.
D. Resources
• Assets folder – styles (raygui), tilemap data, textures, fonts, sounds (if any).
Interactions & data flow
1. App initializes Raylib → creates window & context
2. App initializes Flecs world → registers components & systems
3. Resource loader reads TMX/maps/styles → registers assets in ECS (via tilemap and GUI systems)
4. Game loop (per frame):
a. engine.input systems read user input → write Input components
b. player & ai systems consume Input & AI components → update desired velocities
c. engine.physics systems detect & resolve collisions → update Position/Velocity components
d. gameplay systems (spawn, damage, health, cooldown) → update gameplay state
f. debug systems optionally overlay debug info on screen
g. ecs progress to next frame, clear transient data
5. App finalizes & closes context
Architectural patterns & design principles
• Entity Component System (decoupled data & behavior)
• Modular design: each feature group (input, physics, rendering, gameplay, AI, debug) lives in its own module with its own pipeline steps.
• Pipeline steps: ordered phases per frame (e.g., input → update → physics → rendering).
• Data-driven: components are plain data; systems operate only on relevant component combinations via Flecs queries.
Step-by-step for the Principal Software Engineer
4. Component flows: which systems read/write which component types.
5. Build-time dependencies: tmxlite nested in external/, raygui.h in include/.