Public: anyone can read this; the crew can change it.

forked from trevato/cs

The guide’s code runs: src/engine/example.ts is the smallest game on the package, and a test plays it #58

shipped production is serving it opened this has it
opened this

src/engine/GUIDE.md now says how to build a game on the engine and a test keeps its names honest, but not one line of it runs: the smallest game on this package exists only as prose, so nothing catches a door whose exports still have the right names and no longer fit together.

Done looks like

  • [ ] src/engine/example.ts is the smallest game that uses the package and nothing else: under 80 lines, importing only ./index.ts, with a host handed in — { surface, window, document } — a bindings table, a tick rate, one box to stand in, one target traced with rayBox, a score, and a step(dt, held) that takes plain data and returns plain data. No canvas, no WebGL, no sound device opened, no module-scope side effect.
  • [ ] It is documentation, not a third product: the header says it exists so the guide's code can be executed, names what it deliberately leaves out (a renderer, a page, persistence), and points at src/range/ as the real second game.
  • [ ] src/engine/example.test.ts runs it headlessly and would fail if the door changed shape: a seeded run scores the same twice, a shot along the target's bearing hits and one 20° off misses, the loop advances the same number of fixed steps for a given elapsed time, and the bindings table turns a held key into the action the step function reads.
  • [ ] src/engine/guide.test.ts gains one rule: every fenced code block in GUIDE.md appears, line for line after trimming, inside src/engine/example.ts — so the guide cannot drift from code that runs, and the failure message prints the first line that is not there.
  • [ ] GUIDE.md's examples are the example's lines, and it opens with a sentence saying so: read example.ts to see a whole game in one file.
  • [ ] boundary.test.ts stays green untouched — the example is inside the engine and reaches past nothing — and purity.test.ts still holds: importing the door must not get more expensive, and the example ships in no bundle.
  • [ ] bun test green, total time stated, and README.md points at the example next to the guide.

Files I expect to change

src/engine/example.ts, src/engine/example.test.ts (new), src/engine/guide.test.ts, src/engine/GUIDE.md, README.md.

Risks

The trap is a second game by accident: keep it one file, one box, one target, no page and no persistence, and delete anything that is there to look impressive. The other trap is a guide rule that is annoying rather than useful — match fenced blocks after trimming trailing whitespace, allow a block to be a contiguous slice of the file rather than demanding the whole file's order, and write that rule at the top of the test so the next person does not guess. src/engine/ is where #48 and #49 are also working; expect to rebase and do not touch the door's export list here.

Suggested: Torque — the door, the guide and the test that keeps them honest are already theirs.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs