From 2dfddee8c6fab6eb76cbfe3d95f7c30bfb870702 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Fri, 25 Sep 2026 21:53:00 -0300 Subject: sketchbook: what the game's review needed - input.started: true on the first update of a run, never after a reload, for a sketch to stop what should not resume from saved state. - A console line that errors fails its script. Sketch commands answer unknown, done or failed (abi.Outcome) instead of a bool that hid errors. - addScript also takes the hot-reloadable library, run through the generic host, so scripts can reload a real build. - Sounds that do not load are .none, not an empty clip. - sk_tag reads an enum field's tag name from the web build, for tests. --- README.md | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'README.md') diff --git a/README.md b/README.md index 6531fcd..62e5ab1 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,9 @@ An app is an ordinary module. Every declaration is optional: `update` sees `input.events`: pointer, wheel, key, text, `cancel` (focus loss, console) and one `tick` per frame carrying `dt`. Recorded ticks make -time-driven sketches replay exactly. +time-driven sketches replay exactly. `input.started` is true on the first update after +the program starts, never after a reload: state is saved, so this is where +to stop what should not resume on its own. `draw` gets a `Frame`: `clear`, `fill`, `image`, `text`, `print`, `clip`, `canvas`, `cursor`, `voice`, `audio`, `pixels`, `quit`, plus `f.arena` (frame @@ -95,7 +97,10 @@ queued and played. sketch. - **Scripts** (`--headless --fresh --script file`) drive the same routing and frames as a player: `click`, `key`, `type`, `console`, `expect field value`, - `expect-audio`, `screenshot`, `load`, `await-reload`. + `expect-audio`, `screenshot`, `load`, `reload`, `await-reload`. A failed + `expect`, or a console line that errors (a sketch command returning an + error included), fails the script. Headless always means offscreen, even + with `SDL_VIDEO_DRIVER` set, and GPU work still runs, into a texture. - **GPU.** The host's 2D renderer runs on an SDL GPU device, which also runs sketches' GPU passes. Without a GPU it falls back to any renderer. - **Memory.** SDL allocations go through a leak-checking allocator; a leak @@ -121,9 +126,9 @@ pub fn build(b: *std.Build) void { | --- | --- | | `app.addLibrary()` | the hot-reloadable shared library | | `app.addExecutable()` | host and sketch linked into one binary | -| `app.addWeb(.{ .assets = ... })` | the wasm module and a ready-to-serve directory | +| `app.addWeb(.{ .assets = ... })` | the wasm module and a ready-to-serve directory; tests can read its state by path with `sk_field` (numbers) and `sk_tag` (enum tag names) | | `app.addRun(lib, .{})` | the generic host running the installed library | -| `app.addScript(exe, file, .{})` | a headless, fresh-state scripted run | +| `app.addScript(exe_or_lib, file, .{})` | a headless, fresh-state scripted run, of the executable or of the library through the host (so the script can `reload` it) | | `app.addProbe(state)` | the probe on a state file | | `app.addTest(.{})` | tests with the app importable as `app` | -- cgit v1.3