No description
  • C 52.7%
  • Rust 43.4%
  • C++ 2%
  • Python 1.1%
  • CMake 0.6%
  • Other 0.2%
Find a file
slopper 2eb559fcc0 game: M2 headless smoke harness (GLK_SMOKE_* grammar)
- src/app/smoke.rs: SmokeScript from env (frames, screenshot, held keys,
  choice-digit queue, state seed, examine/talk/exit/cutscene/audio/
  reactivity/death-restart/menu/npc-log/player-pos), boot apply, per-frame
  drivers (auto panel opens, exit travel, periodic audio/npc/dbg logs),
  exit block: screenshot + final audio/death lines + 'SMOKE OK frames=N'
  + exit 0 (C app.c:505-548, 603-640, 1775-1954, 2862)
- hooks into the existing systems: choice digits in interact's panel
  command path, 0.5 s cutscene advance (CutsceneState.smoke_t), death
  auto-restart, fired-reactivity rule prints, held smoke keys in movement
- verified live: talk+choice+audio+npc+screenshot run, m5_demo reactivity
  prints, smoke exit travel, options-screen boot (vision-verified), all
  runs SMOKE OK + exit 0; three parser unit tests
- PARITY-AUDIT M2 RESOLVED; docs/build-and-tests.md rebuild subsection
2026-12-04 20:56:14 -06:00
content checkpoint: C++ tree before C rewrite (SDL2) 2026-10-20 19:00:29 -06:00
cutscenes checkpoint: C++ tree before C rewrite (SDL2) 2026-10-20 19:00:29 -06:00
docs game: M2 headless smoke harness (GLK_SMOKE_* grammar) 2026-12-04 20:56:14 -06:00
engine housekeeping: drop RESUME/M5-Goal scratch docs; C editor reference sources; CMake tweaks 2026-12-04 20:33:09 -06:00
gravelocked-rust game: M2 headless smoke harness (GLK_SMOKE_* grammar) 2026-12-04 20:56:14 -06:00
old housekeeping: drop RESUME/M5-Goal scratch docs; C editor reference sources; CMake tweaks 2026-12-04 20:33:09 -06:00
sprites checkpoint: C++ tree before C rewrite (SDL2) 2026-10-20 19:00:29 -06:00
tests housekeeping: drop RESUME/M5-Goal scratch docs; C editor reference sources; CMake tweaks 2026-12-04 20:33:09 -06:00
tools housekeeping: drop RESUME/M5-Goal scratch docs; C editor reference sources; CMake tweaks 2026-12-04 20:33:09 -06:00
.gitignore checkpoint: C++ tree before C rewrite (SDL2) 2026-10-20 19:00:29 -06:00
CMakeLists.txt housekeeping: drop RESUME/M5-Goal scratch docs; C editor reference sources; CMake tweaks 2026-12-04 20:33:09 -06:00
README.md Update README.md 2026-12-04 20:52:09 -06:00

Gravelocked

Isometric narrative RPG — real-time movement, proximity interaction, DE-style dialogue, no combat. Two state axes (Madness / Bond) gate dialogue and entity states.

Status: milestones M0-M5 complete (save/load is the only remaining milestone). The engine is C11 on SDL3 (sdl3-ttf for text, sdl3-mixer for audio, libcjson for content, zlib for the PNG codec — no image library, no C++ JSON DOM; the old C++ tree is retired, and its sources stay readable under /home/slopper/cpp-backup/ for comparison). The audio stack (SFX/music/ambient/dynamic-tension, WAV + OGG via a vendored stb_vorbis), the shared action/event system, WorldReactivity, and the death flow are in. Four demo rooms (content/rooms/: farmhouse bedroom, farmhouse hallway, M5 demo, M5 demo 2) plus a GUI content editor with a System tab (events / reactivity / death / palettes / audio). The game logic runs on a 30 Hz tick scheduler (decoupled from the render rate), with position interpolation so 30 Hz logic looks smooth at 60/120 Hz rendering: 1 tick every 2 frames at 60 Hz, 1 tick every 4 frames at 120 Hz.

Build

cmake -B build
cmake --build build -j 8

Dependencies come in via pkg-config: sdl3 sdl3-ttf sdl3-mixer libcjson zlib (see docs/build-and-tests.md for the target/source map). Targets: build/gravelocked (game), build/glk_editor (content editor), build/glk_tests (unit tests).

Run

./build/gravelocked

WASD or the arrow keys move the player, E examines/interacts, ESC opens the menu (resolution + key rebinding), F12 takes a screenshot.

./build/glk_editor [path/to/room.json]

The content editor (default window 1920x1080; the UI is authored in a fixed 1440x900 space and scaled to the live window size, no letterbox).

Unit tests

./build/glk_tests

Expect N passed, 0 failed (currently 496) and exit code 0.

Headless smoke test

GLK_SMOKE_FRAMES=300 SDL_VIDEODRIVER=dummy ./build/gravelocked

Runs 300 frames with the dummy video driver (no display needed) and prints SMOKE OK frames=300. The editor has its own GLK_EDITOR_* hooks (frames, shots, grid ops, saves, scene loads). docs/build-and-tests.md enumerates every knob of both binaries — GLK_SMOKE_FRAMES, _SCREENSHOT, _KEYS, _CHOICE, _EXAMINE, _TALK, _EXIT, _CUTSCENE, _AUDIO, _REACTIVITY, _DEATH_RESTART, _MENU, plus the non-smoke GLK_STATE, GLK_PLAYER_POS, GLK_NPC_LOG, GLK_DEBUG_INPUT, GLK_SKIP_TTF, GLK_SKIP_GEOM, GLK_FONT — and the AddressSanitizer/UBSan command lines.

Force a specific start scene with GLK_SCENE=<id> (e.g. GLK_SCENE=m5_demo) or GLK_CONTENT=<path to a .json> (the file's stem is used as the id); GLK_SCENE takes precedence. An unknown id warns and falls back to the first scene.

The M5 demo exercises the audio, event, reactivity and death surfaces (see docs/core.md): GLK_SMOKE_AUDIO (periodic audio-layer state: music/ambient/tension playing + tension intensity = f(M,B)), GLK_SMOKE_REACTIVITY (print WorldReactivity rule firings), GLK_SMOKE_DEATH_RESTART (auto-restart after death). The audio stack runs in "silent" mode when no audio device is available (headless), so the state is still tracked and printed. Example M5 demo run:

GLK_SMOKE_FRAMES=120 GLK_SMOKE_AUDIO=1 GLK_SMOKE_EXAMINE=1 \
  GLK_PLAYER_POS=8,6 GLK_CONTENT=content/rooms/m5_demo.json \
  SDL_VIDEODRIVER=dummy ./build/gravelocked

M5: audio, events, reactivity, death

  • Audio stack (engine/audio): decode.c turns WAV/OGG into PCM (OGG via a vendored single-header stb_vorbis, no new system dependency); mixer.c layers that on top of SDL3_mixer (MIX_*). Four layers — SFX (8 concurrent channels), music (two slots for crossfade), ambient (per-room loop), and a dynamic tension layer whose gain tracks glk_tension_intensity(madness, bond). WAV and OGG decode to 16-bit PCM. Clips are declared per scene in a content audio library. In headless (no device) the mixer runs "silent" and still tracks state. See docs/audio.md.
  • Shared action executor (engine/events): a single action vocabulary (play_sfx / play_music / ambient / tension / set_flag / M / B / fire_event / play_cutscene / palette / show / hide / unlock / lock / die). Every env change is a content JSON action routed through ActionContext, which is the only writer to GameState (along with dialogue choice effects). String sugar ("sfx:x", "M:0.2", "palette:fever") is normalised to canonical objects.
  • Events: a scene's events map is id -> { name, actions[] }, fireable from interactables (event: on examine), dialogue choice effects, and reactivity.
  • WorldReactivity: declarative { when, in, do } rules evaluated on state change + scene entry; M gates perception (palette/visibility/audio), B gates access (doors). Shifts are legible (HUD flash + SEEABLE changes).
  • Death: a die <cause> action opens a named, cause-specific death screen; Restart resets M/B/flags/scene, Quit exits. Reachable via an interactable and via an M/B-gated dialogue choice.
  • Demo: content/rooms/m5_demo.json exercises all of the above (an idol that fires a named SFX + M bump; a reactivity band that shifts palette / visibility / a locked door; two death paths — interact and dialogue-gated).

Layout

engine/core/      app loop, window, input, all game rendering, menus, panels
engine/render/    iso transform math + PNG encode/decode (zlib; screenshots, editor shots)
engine/world/     room (tile grid + columns), SpriteDef, EntityState
engine/content/   RoomContent + JSON round-trip + validation
engine/events/    shared action vocabulary + event system + reactivity (pure)
engine/audio/     decode (WAV + vendored stb_vorbis OGG) + SDL3_mixer playback layers
engine/scene/     scene discovery / create / save
engine/dialogue/  node-graph dialogue engine (pure)
engine/state/     M/B game state (pure)
engine/npc_ai/    NPC presence state machine + A* (pure)
engine/anim/      sprite-sheet animation logic (pure)
engine/entities/  player
engine/input/     key bindings (persisted, rebindable)
engine/util/      asciiFallback, path resolution, dynamic collections (StrList/StrSet/GlkMap)
engine/editor/    glk_editor GUI (editor.c, editor_model.c, editor_draw.c,
                  editor_draw_panes.c, editor_util.c, main.c + editor.h,
                  editor_internal.h — one GlkEditor struct, ed_* free functions)
content/          live content: rooms/*.json + audio/* (placeholder clips) + scenes.json

sprites/  cutscenes/  tools/  tests/  config/ (git-ignored runtime config)

Milestones

  • M0: app loop + window + input + 2D renderer + one depth-sorted iso room + movable player
  • M1: wall collision + one interactable + examine panel
  • M2: dialogue engine (data-driven) + one tree + M/B state + GUI content editor
  • M3: sister NPC (pathing/presence) + proximity dialogue + data-driven scenes
  • M4: portraits, cutscenes, sprite-sheet animation, player-centred camera, demo content
  • M5: audio stack (SFX/music/ambient/tension, WAV+OGG), shared action executor + events, WorldReactivity, death screens (interact + dialogue-gated), System-tab editor, entity states + M/B-gated dialogue; demo scene + docs
  • M6: save/load (not started)