How gianlourbano/brown works
Project type and purpose
• This is a monolithic C++ “Brown” game engine plus a terminal‐based 2D game built on top of it.
• The engine provides an ECS framework, core services (event, time, memory, debug), graphics (ncurses via window/framebuffer), input, math, and a small custom STL.
Top-level file structure analysis
• Game/src/engine: the engine core.
· core: ECS (entities, components, systems)
· event, time, memory, debug, math, std utilities
· graphics (window & framebuffer)
· input
· engine.cpp/h (initialization & main loop), state manager
• Game/src/assets: game content & logic
· items & inventory
· map_gen (level/world generators)
· scripts (NPC, boss, doors, UI controllers, player, projectiles, AI)
· states (menu, room, inventory, game over)
• Game/src/main.cpp: entry point
• Makefile & ncurses dependency
Key insights from README
• Built with g++/make, relies on ncurses ≥ 6
• Single binary, runs in terminal
• WASD movement, T shooting, I for inventory, M for world advance
Components
a. Main Application Layer
• Entry Point (main.cpp)
• Makefile / Build System (g++/ncurses)
b. Engine Core (blue)
• Initialization & Game Loop
• Core Services: EventManager, Time, MemoryAllocator, Debugger
• ECS Framework
· EntityManager, ComponentManager, SystemManager
· Systems: RenderSystem, AnimationSystem, UI_System, ScriptsSystem
• Graphics Subsystem
· Window, Framebuffer (ncurses adapter)
• Input Subsystem
• Math & Custom Std Utilities
c. Game Layer (green)
• & World Generators
• Scriptable Logic: NPC, boss, door controllers, AI, healthbar, score, inventory renderer, projectile logic
• Item & Inventory Model
• State Manager & Game States
· MenuState, RoomState, InventoryState, GameOverState
d. External Dependencies (gray)
• ncurses library
Interactions & Data Flow
1. Build System compiles all engine + game code → executable
2. main.cpp → Engine::init() → load assets via AssetLoader
3. Engine’s Game Loop (update):
a. InputSubsystem polls keyboard → EventManager
b. EventManager dispatches to ECS / ScriptSystem / UI
c. ECS Framework updates all registered Systems in order (AI/scripts → animation → UI → render)
d. Game-specific systems (map_gen, item pickup, state transitions) run via ScriptsSystem & custom controllers
e. RenderSystem draws to Framebuffer/Window via ncurses
f. Time service enforces delta / frame rate
4. StateManager switches between game states (menu, room, inventory, game over)
Architectural Patterns & Principles
• Layered Architecture: Engine Core ← Game Layer ← main
• ECS for decoupled game logic
• Single Responsibility: each subsystem (graphics, input, memory) isolated
• Event-driven within the core loop
• Custom memory & std for tighter control and portability