# FBC: NIGHT SHIFT — Technical Design ## Stack (locked) - **C++23** (GCC 13+; developed on GCC 16) - **CMake 3.15+** (developed on 4.3) - **raylib 6.2**, pinned via CMake `FetchContent` (`GIT_TAG 6.2`, link target `raylib`). 6.2 is the current release (Oct 2026) and fixed CMake-4.x build issues; builds GLFW from source (X11/GL dev headers required). raylib 6.x adds the Image/Draw API alignment (procedural textures) and skeletal model animation (`UpdateModelAnimation`, GLTF/IQM/M3D) — the per-unit upgrade path from standees to animated bosses. - No other third-party deps until they earn their place. Data lives in C++ tables (JSON only when content volume demands it). ## Repo layout ``` CMakeLists.txt assets/{sprites,env,fonts,audio,shaders} docs/ # this is the design source of truth src/ main.cpp # CLI (--seed N), window, fixed-tick loop core/ # NO raylib includes here. math, rng (PCG32), events game/ # NO raylib includes here. simulation input.hpp # InputState contract (filled by main from raylib) corruption.* # RoR2-style difficulty coefficient + tier ladder player.* # movement, dash, stats enemies.* # archetypes, AI steering + separation, contact damage weapons.* # auto-fire, projectiles, targeting pickups.* # XP shards, magnet game.* # Game class: state machine, fixed-tick update, level-ups render/ # raylib lives here only (+ main.cpp) presenter.* # 3D diorama camera, billboards, blob shadows, world bars ui.* # HUD, Board Directive cards, death screen ``` ## Architecture decisions 1. **Sim/render split.** `core/` and `game/` never include raylib; `main.cpp` fills an `InputState` and the presenter reads the world. This keeps the sim portable (the planned `--headless --bot-runs` pacing telemetry), testable, and lets the presenter be swapped (pure 2D, full 3D) without touching game logic. The sim is a floor-plane (Vec2) game regardless of how it is drawn. 2. **Fixed 60 Hz logic tick** with a render-rate accumulator in `main.cpp`. 3. **Deterministic seeded RNG (PCG32)** in the sim; presentation-only randomness (screen shake) uses raylib's RNG and cannot touch game state. 4. **Event queue** (`EventQueue`, consumed and cleared by the presenter each frame): kills, hits, player damage, tier-ups -> VFX / SFX / screen shake / damage numbers. 5. **Object pooling** (`core/pool.hpp`, dense swap-remove pool — no alloc churn after warmup, O(alive) iteration) for projectiles, enemies, shards. 6. **Spatial hash** (`core/spatial_hash.hpp`, sorted-bucket, zero per-insert allocation) for enemy separation and projectile collision at horde scale. 7. **Credit-based spawn Director** (`game/director.*`) with RoR2's "too cheap" rule and the elite-bank rule (implemented in M2). ## Rendering pipeline (hybrid) - `Camera3D` three-quarter view following the player. - Ground slab + `DrawGrid` + procedural box pillars/walls (brutalist kit). - **Blob shadows** (flattened cylinders) — no shadow maps in raylib core; blob shadows *reinforce* the standee look, not a compromise. - **2D standees:** `DrawBillboard` with a procedurally generated soft-disc texture (`GenImageGradientRadial`), tinted per entity; manual back-to-front sort by camera distance (raylib billboards need explicit draw order). - **UI anchoring:** `GetWorldToScreen` for health bars over entities. - Post FX (M5): draw to `RenderTexture`, full-screen shaders (VHS, chromatic aberration) with uniforms keyed to the corruption coefficient. ## Conventions - `snake_case` files/functions, `PascalCase` types, `kConstant` for constants. - `#pragma once` headers; include paths relative to `src/` (`#include "game/game.hpp"`). - Compile clean with `-Wall` semantics; no warnings ignored globally. ## CLI - `--seed N` run seed (implemented). - `--screenshot ` saves a PNG of the framebuffer (optionally `--screenshot-at `, default 3 s); F12 saves one on demand (implemented — dev tool, works under Wayland where root-window grabs cannot see composited windows). - `--screenshot-on-levelup ` captures the frame when the Board Directive cards appear (implemented — UI validation). - `--bot` kiting autopilot: seeks shards, repels enemies, dashes, auto-picks the first Directive (implemented — validation tool and the seed of the M6 balance-bot). - `--headless --bot-runs N` pacing telemetry (planned M6).