How tmewett/broguece works
Purpose and entry points
Brogue CE is a native C, single-player roguelike with procedurally generated dungeon runs, turn-based strategy, persistent recordings, and selectable graphical/terminal front ends. Process startup is src/platform/main.c, which selects platform services and enters core gameplay in src/brogue/RogueMain.c. Shared game declarations and global state contracts center on src/brogue/Rogue.h and src/brogue/Globals.h.
Platform abstraction and rendering
The core does not directly own OS/UI implementation. src/platform/platform.h defines the platform boundary; implementations include SDL2 graphics in src/platform/sdl2-platform.c, curses terminal support in src/platform/curses-platform.c, browser support in src/platform/web-platform.c, and headless/null behavior in src/platform/null-platform.c. Tile rendering and bundled tile asset handling are in src/platform/tiles.c and bin/assets/tiles.bin. Linux releases require SDL2 and SDL2_image.
Game lifecycle and turn control
src/brogue/RogueMain.c coordinates menus, new or resumed games, command processing, per-turn updates, and win/death end states. User-facing title/menu flow is separated in src/brogue/MainMenu.c; input/output mediation is in src/brogue/IO.c. Time/turn semantics are handled by src/brogue/Time.c, while global mutable run state is organized through src/brogue/Globals.c and src/brogue/GlobalsBase.c.
Dungeon generation and spatial simulation
Dungeon construction is concentrated in src/brogue/Architect.c, producing level geometry, rooms, terrain, machines, and placements. Grid-level state and cell operations live in src/brogue/Grid.c. src/brogue/Dijkstra.c supplies distance-map/pathing calculations used by movement and AI; src/brogue/Light.c updates visibility and illumination. These systems form the primary spatial boundary consumed by player movement, monsters, and rendering.
Entities, player actions, and combat
Player movement and interaction resolve through src/brogue/Movement.c; creature state, AI, spawning, and ally behavior through src/brogue/Monsters.c; and attack/damage/status resolution through src/brogue/Combat.c. Items, inventory, consumables, equipment, and generated loot are owned by src/brogue/Items.c. Core flows are: input → action validation → map/entity mutation → combat or item effects → lighting/pathing/turn advancement → platform redraw.
Content tables, variants, and developer modes
Static game rules and probability/power data are represented in src/brogue/PowerTables.c. Variant-specific global configurations allow Brogue, Bullet Brogue, and Rapid Brogue builds without replacing core systems: src/variants/GlobalsBrogue.c, src/variants/GlobalsBulletBrogue.c, and src/variants/GlobalsRapidBrogue.c. Debug/developer controls are isolated in src/brogue/Wizard.c.
Persistence, replayability, and delivery
Run recordings/replay data are managed by src/brogue/Recordings.c; curated deterministic seeds are handled by src/brogue/SeedCatalog.c. This supports regression validation of procedural generation and gameplay outcomes. Builds are Make-based, with common rules in make/brogue.mk and OS-specific targets in make/windows.mk and make/o.mk; CI is defined in .github/workflows/build.yml and .github/workflows/test.yml.
Main entry points: RogueMain.c Game coordinator · Movement.c Player actions · sdl2-platform.c SDL, curses, web & null · brogue.mk Make build targets
Components 23
Platform & front ends
- Process startup
src/platform/main.c - Platform boundary
src/platform/platform.h - SDL, curses, web & null · Selectable graphics, terminal, browser, and headless implementations.
src/platform/sdl2-platform.c - Tile renderer
src/platform/tiles.c - Tile assets
bin/assets/tiles.bin
Game lifecycle
- Game coordinator · Coordinates menus, runs, commands, turns, and end states.
src/brogue/RogueMain.c - Title & menus
src/brogue/MainMenu.c - Input/output mediation
src/brogue/IO.c - Run state contracts
src/brogue/Globals.c - Core declarations
src/brogue/Rogue.h - Turn scheduler
src/brogue/Time.c
Dungeon & simulation
- Dungeon generator
src/brogue/Architect.c - Grid & cell state
src/brogue/Grid.c - Pathing & lighting · Distance maps drive navigation; lighting updates visibility.
src/brogue/Dijkstra.c - Player actions
src/brogue/Movement.c - Creatures & AI
src/brogue/Monsters.c - Combat & status
src/brogue/Combat.c - Items & inventory
src/brogue/Items.c - Rule tables
src/brogue/PowerTables.c
Replay & delivery
- Recordings & seeds · Run recordings and curated seeds support reproducible validation.
src/brogue/Recordings.c - Game variants · Brogue, Bullet Brogue, and Rapid Brogue select variant state configuration.
src/variants/GlobalsBrogue.c - Make build targets · Common and OS-specific Make targets build platform and variant combinations.
make/brogue.mk - Build & test CI
.github/workflows/build.yml
Connections 26
- Process startup → Platform boundary: selects services
- Process startup → Game coordinator: enters
- SDL, curses, web & null → Platform boundary: implements
- Tile renderer → Tile assets: loads
- SDL, curses, web & null → Tile renderer: uses for graphics
- Game coordinator → Title & menus: drives
- Game coordinator → Input/output mediation: processes commands through
- Input/output mediation → Platform boundary: mediates I/O
- Game coordinator → Turn scheduler: advances turns
- Game coordinator → Run state contracts: coordinates state
- Core declarations → Run state contracts: declares contracts for
- Game coordinator → Dungeon generator: creates levels
- Dungeon generator → Grid & cell state: constructs
- Player actions → Grid & cell state: mutates
- Player actions → Pathing & lighting: queries paths and visibility
- Creatures & AI → Pathing & lighting: uses pathing
- Player actions → Combat & status: triggers
- Combat & status → Creatures & AI: updates creatures
- Player actions → Items & inventory: interacts with
- Rule tables → Dungeon generator: governs generation
- Rule tables → Items & inventory: governs effects
- Game coordinator → Recordings & seeds: records and replays runs
- Game variants → Run state contracts: supplies selected configuration
- Make build targets → SDL, curses, web & null: builds targets
- Make build targets → Game variants: selects variant
- Build & test CI → Make build targets: runs