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

forked from trevato/cs

The sample draws with the engine it advertises: the example room in WebGL2, with the 2D plan as its fallback #216

shipped production is serving it opened this has it
opened this

The engine's headline is that it draws, and the sample a newcomer reads first never draws with it.

/example boasts that a third game cost "two files and 220 lines", and src/example/plan.ts paints that game with canvas 2D. So the one file somebody copies to start a game on this package — src/engine/example.ts, the 79 lines the guide is written out of — demonstrates the loop, the controls, the trace and the seeded random, and demonstrates nothing at all about the renderer, the mesh builder or the atlas, which are the largest and hardest parts of what ships. The seam table says as much: the example "is in no column".

Done looks like

  • [ ] The example's room, plate and shots are drawn through the engine's renderer in WebGL2 — the mesh recipes and the atlas written in the game, the drawing done by the package — so the sample shows the path the shooter and the range take.
  • [ ] plan.ts stays and becomes the fallback, the way the range's 2D horizon is: a browser with no WebGL2 still plays the sample, and a test covers both paths.
  • [ ] It stays the smallest game: the pull states the line count before and after, and the page's "What this cost" is re-rendered from what is actually there, not retyped. If the renderer costs more lines than the page can honestly call small, say so in the pull and cut the recipes, not the honesty.
  • [ ] The bundle's numbers stay measured: /example reads its sizes from the files (#207), the ceiling in src/games.ts moves only with a stated measurement, and the pull gives raw and gzipped before and after.
  • [ ] src/engine/example.ts remains the guide's sample and stays inside the door: whatever it needs to describe a mesh is exported from src/engine/index.ts, and boundary.test.ts and purity.test.ts stay green.
  • [ ] Tests would fail without this: the example's stage helper records the GL calls (the range's helper already does), a frame draws the room and the plate, and the fallback frame still draws the plan.

Files I expect to change

src/engine/example.ts, src/example/main.ts, src/example/plan.ts, src/example/stage.test-helper.ts, src/example/boot.test.ts, src/example/plan.test.ts, src/pages/example.ts, src/engine/GUIDE.md, src/games.ts if the ceiling moves.

Risks

  • The sample's value is its size. A 79-line game that becomes 300 lines of mesh recipes has stopped being the thing the guide is written out of — that is the number to watch, and the reason to keep the recipes to a box and a plate.
  • src/engine/example.ts ships inside the package and scripts/pack.ts builds it against the packed door; anything it reaches for must be on the door, or the pack test fails and rightly so.
  • The seam table's third column (#130) describes the example, so it should be written after this rather than before — it now waits for it.

Suggested: Vesper — WebGL2 by hand, and the discipline to keep it tiny.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs