hayao 0.4.0 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. package/design/00-process/README.md +49 -0
  2. package/design/00-process/composition.md +148 -0
  3. package/design/00-process/core-loop.md +146 -0
  4. package/design/00-process/intent-to-brief.md +128 -0
  5. package/design/00-process/pillars.md +139 -0
  6. package/design/00-process/refine-and-handoff.md +156 -0
  7. package/design/00-process/the-twist.md +108 -0
  8. package/design/10-anchors/README.md +99 -0
  9. package/design/10-anchors/age-of-empires.md +103 -0
  10. package/design/10-anchors/baba-is-you.md +127 -0
  11. package/design/10-anchors/balatro.md +132 -0
  12. package/design/10-anchors/celeste.md +136 -0
  13. package/design/10-anchors/civilization.md +101 -0
  14. package/design/10-anchors/dead-cells.md +125 -0
  15. package/design/10-anchors/factorio.md +100 -0
  16. package/design/10-anchors/hades.md +127 -0
  17. package/design/10-anchors/into-the-breach.md +125 -0
  18. package/design/10-anchors/it-takes-two.md +104 -0
  19. package/design/10-anchors/loop-hero.md +131 -0
  20. package/design/10-anchors/nuclear-throne.md +130 -0
  21. package/design/10-anchors/outer-wilds.md +107 -0
  22. package/design/10-anchors/overcooked.md +102 -0
  23. package/design/10-anchors/peggle.md +133 -0
  24. package/design/10-anchors/reigns.md +99 -0
  25. package/design/10-anchors/return-of-the-obra-dinn.md +108 -0
  26. package/design/10-anchors/rimworld.md +101 -0
  27. package/design/10-anchors/shadow-of-mordor.md +106 -0
  28. package/design/10-anchors/slay-the-spire.md +127 -0
  29. package/design/10-anchors/starcraft.md +98 -0
  30. package/design/10-anchors/stardew-valley.md +103 -0
  31. package/design/10-anchors/tetris.md +122 -0
  32. package/design/10-anchors/vampire-survivors.md +122 -0
  33. package/design/20-genres/README.md +62 -0
  34. package/design/20-genres/action-adventure.md +126 -0
  35. package/design/20-genres/auto-battler.md +121 -0
  36. package/design/20-genres/bullet-hell.md +123 -0
  37. package/design/20-genres/city-builder.md +124 -0
  38. package/design/20-genres/coop-chaos.md +124 -0
  39. package/design/20-genres/deckbuilder.md +122 -0
  40. package/design/20-genres/exploration.md +131 -0
  41. package/design/20-genres/farming-sim.md +122 -0
  42. package/design/20-genres/grid-puzzle.md +126 -0
  43. package/design/20-genres/horde-survival.md +128 -0
  44. package/design/20-genres/incremental.md +120 -0
  45. package/design/20-genres/match3.md +120 -0
  46. package/design/20-genres/metroidvania.md +132 -0
  47. package/design/20-genres/narrative-decisions.md +122 -0
  48. package/design/20-genres/physics-arcade.md +124 -0
  49. package/design/20-genres/precision-platformer.md +127 -0
  50. package/design/20-genres/racing.md +126 -0
  51. package/design/20-genres/rhythm.md +125 -0
  52. package/design/20-genres/roguelike.md +122 -0
  53. package/design/20-genres/rts.md +169 -0
  54. package/design/20-genres/stealth.md +125 -0
  55. package/design/20-genres/survival-horror.md +124 -0
  56. package/design/20-genres/tactics.md +123 -0
  57. package/design/20-genres/tower-defense.md +120 -0
  58. package/design/30-systems/README.md +69 -0
  59. package/design/30-systems/accessibility.md +110 -0
  60. package/design/30-systems/boss-design.md +126 -0
  61. package/design/30-systems/build-diversity.md +120 -0
  62. package/design/30-systems/collectibles.md +108 -0
  63. package/design/30-systems/combat-model.md +113 -0
  64. package/design/30-systems/coop-and-competition.md +118 -0
  65. package/design/30-systems/counter-systems.md +115 -0
  66. package/design/30-systems/crafting.md +115 -0
  67. package/design/30-systems/difficulty-and-dda.md +114 -0
  68. package/design/30-systems/economy.md +117 -0
  69. package/design/30-systems/emergent-systems.md +114 -0
  70. package/design/30-systems/encounter-design.md +107 -0
  71. package/design/30-systems/enemy-ai.md +121 -0
  72. package/design/30-systems/enemy-archetypes.md +117 -0
  73. package/design/30-systems/faction-asymmetry.md +144 -0
  74. package/design/30-systems/grace.md +124 -0
  75. package/design/30-systems/mastery-curve.md +116 -0
  76. package/design/30-systems/meta-progression.md +114 -0
  77. package/design/30-systems/onboarding.md +115 -0
  78. package/design/30-systems/procgen-design.md +118 -0
  79. package/design/30-systems/progression.md +120 -0
  80. package/design/30-systems/resource-loops.md +112 -0
  81. package/design/30-systems/reward-schedules.md +124 -0
  82. package/design/30-systems/save-and-checkpoint.md +113 -0
  83. package/design/30-systems/session-structure.md +113 -0
  84. package/design/30-systems/skill-trees.md +111 -0
  85. package/design/30-systems/status-effects.md +111 -0
  86. package/design/30-systems/tech-tree.md +112 -0
  87. package/design/30-systems/telegraphs.md +106 -0
  88. package/design/30-systems/unit-rosters.md +123 -0
  89. package/design/40-worldbuilding/README.md +49 -0
  90. package/design/40-worldbuilding/aesthetic-direction.md +155 -0
  91. package/design/40-worldbuilding/faction-identity.md +136 -0
  92. package/design/40-worldbuilding/naming-and-tone.md +130 -0
  93. package/design/40-worldbuilding/narrative-delivery.md +129 -0
  94. package/design/40-worldbuilding/theme-vectors.md +134 -0
  95. package/design/40-worldbuilding/worldbuilding-scaffold.md +132 -0
  96. package/design/50-patterns/README.md +54 -0
  97. package/design/50-patterns/anti-frustration.md +121 -0
  98. package/design/50-patterns/emergence.md +121 -0
  99. package/design/50-patterns/feedback-loops.md +121 -0
  100. package/design/50-patterns/juice-choreography.md +124 -0
  101. package/design/50-patterns/mastery-and-flow.md +121 -0
  102. package/design/50-patterns/pacing-and-tension.md +120 -0
  103. package/design/50-patterns/readability.md +121 -0
  104. package/design/50-patterns/risk-reward.md +120 -0
  105. package/design/CONTRIBUTING.md +183 -0
  106. package/design/INDEX.md +133 -0
  107. package/design/README.md +86 -0
  108. package/design/_TEMPLATE.md +69 -0
  109. package/design/index.json +2720 -0
  110. package/dist/anim/blend.d.ts +68 -0
  111. package/dist/anim/clip.d.ts +87 -0
  112. package/dist/anim/ik.d.ts +40 -0
  113. package/dist/anim/skeleton.d.ts +64 -0
  114. package/dist/hayao.global.js +12 -12
  115. package/dist/index.d.ts +11 -1
  116. package/dist/index.js +1683 -516
  117. package/dist/index.js.map +4 -4
  118. package/dist/index.min.js +12 -12
  119. package/dist/render/canvas2d-core.d.ts +4 -0
  120. package/dist/render/commands.d.ts +19 -0
  121. package/dist/render/lightRun.d.ts +35 -0
  122. package/dist/render/svgString.d.ts +8 -3
  123. package/dist/scene/clipPlayer.d.ts +58 -0
  124. package/dist/scene/ikTarget.d.ts +25 -0
  125. package/dist/scene/light.d.ts +80 -0
  126. package/dist/scene/shadow2d.d.ts +25 -0
  127. package/dist/scene/skeletonDebug.d.ts +28 -0
  128. package/dist/verify/gates.d.ts +25 -0
  129. package/docs/API.md +66 -8
  130. package/docs/CONVENTIONS.md +56 -0
  131. package/package.json +2 -1
@@ -0,0 +1,122 @@
1
+ ---
2
+ id: genre-narrative-decisions
3
+ title: Narrative Decisions
4
+ kind: genre
5
+ tags: [narrative, decisions, reigns, swipe, meters, stewardship, choice, cards]
6
+ summary: Impossible stewardship — every choice double-edged, meters balanced between two ditches; judgement beats any fixed policy.
7
+ use-when: The design is a choice-driven game where balancing competing meters via double-edged decisions IS the gameplay (Reigns-like).
8
+ composes-with: [system-economy, system-emergent-systems, pattern-risk-reward, pattern-feedback-loops, pattern-pacing-and-tension]
9
+ anchors: [anchor-reigns]
10
+ verify-with: docs/FUN.md#21-·-narrative-decisions-reigns-like
11
+ ---
12
+
13
+ # Narrative Decisions
14
+
15
+ **What it is.** You steward something fragile — a kingdom, a ship, a life — through
16
+ a stream of decisions, each with two edges. Every choice moves competing meters; let
17
+ any meter hit a ditch and you lose. The content is the game.
18
+
19
+ **Player fantasy.** *"I'm holding it together by judgement alone."* The weary,
20
+ compulsive pull of one-more-decision, of keeping every plate spinning when every
21
+ plate-spin tips another.
22
+
23
+ ## Pillars
24
+
25
+ 1. **Every choice is double-edged.** No free wins. A decision that helps one meter
26
+ must cost another — the tension is the point. A no-op choice is a dead choice.
27
+ 2. **Meters live between two ditches.** Each meter loses at *both* extremes (too
28
+ little AND too much). You're threading, not maximising. Judgement, not a fixed
29
+ policy, must win (19/20 vs 0/20 in the campaign).
30
+ 3. **Content is the level.** Difficulty, pacing, and voice all live in the card
31
+ deck. When content is data, editorial judgement becomes CI (see below).
32
+
33
+ ## The loop stack
34
+
35
+ | Scale | The beat |
36
+ |---|---|
37
+ | **Moment** | Read a card, weigh two edges, commit; watch the meters twitch. |
38
+ | **Encounter** | A chain of related cards — an arc that pays off or backfires. |
39
+ | **Session** | A reign/run: survive until a doom fires or you reach an ending. |
40
+ | **Meta** | Unlocked arcs/characters/endings; flags carried between runs; the map of what-ifs. |
41
+
42
+ ## Essential systems
43
+
44
+ | System | Why it's load-bearing |
45
+ |---|---|
46
+ | [[world-narrative-delivery]] | Story is told *through* the choices and meters — embedded, not narrated at you. |
47
+ | [[system-economy]] | Meters are currencies with faucets and sinks; the whole game is balancing them. |
48
+ | [[system-emergent-systems]] | Flags/relationships that remember past choices turn a deck into a personal history. |
49
+ | [[pattern-risk-reward]] | Every double-edged card is a push-your-luck bet on which meter can afford the hit. |
50
+ | [[pattern-feedback-loops]] | Meters that feed each other (low treasury → unrest → worse options) create the death spiral. |
51
+
52
+ ## Content & difficulty model
53
+
54
+ - **Editorial judgement is CI.** When choices are data, lint them: unique ids,
55
+ bounded effects (|Δ| ≤ 20), every needs-flag actually settable somewhere, no
56
+ no-op choices, no unreachable cards. The content lint *is* the balance test
57
+ (FUN.md §21).
58
+ - **Doom attribution matters.** Each ending must fire from ITS meter at ITS edge —
59
+ a swapped ending string wrecks the fiction invisibly. Assert every doom fires its
60
+ own ending, at its own edge.
61
+ - **Arcs terminate both ways.** A multi-card arc must be able to resolve well *and*
62
+ badly; a one-way arc is a cutscene.
63
+ - **Prove judgement beats policy.** A balanced-policy bot survives; an
64
+ always-swipe-one-way bot loses (0/20). If a fixed policy wins, the meters aren't
65
+ really ditched on both sides.
66
+ - **Pacing lives in the deck order.** A calm-cards-only stretch is a desert; a
67
+ crisis-cards-only stretch is a death march. Weight the draw so tension breathes —
68
+ a scare, then a reprieve, then the arc's payoff (see [[pattern-pacing-and-tension]]).
69
+ - **Every card is a small risk-reward bet.** The player is betting which meter can
70
+ absorb the hit *this* turn; the fun is that the safe-looking edge is often the
71
+ slow poison. Author both edges to bite differently, never symmetrically.
72
+
73
+ ## Signature-mechanic seeds
74
+
75
+ - **Reigns *but* the advisors lie, and trust is a hidden meter** — you're weighing
76
+ the source, not just the choice (mechanic-swap; composes [[system-emergent-systems]]).
77
+ - **Reigns *but* one deck, played by two rulers taking turns** — competitive or
78
+ co-op stewardship (structure; composes [[genre-coop-chaos]], [[system-coop-and-competition]]).
79
+ - **Reigns *but* your past selves' choices become cards for your heir** — the reign
80
+ is a run in a roguelite dynasty (structure; composes [[system-meta-progression]]).
81
+ - **Reigns *but* the meters are people, and each ditch is a character leaving**
82
+ (theme/tonal — reframes numbers as relationships).
83
+ - **Reigns *but* time-pressured — a card auto-resolves badly if you stall** (constraint;
84
+ adds a real-time clock over the turn-based deck).
85
+
86
+ ## Common pitfalls
87
+
88
+ - **Dominant strategy.** If "always favour treasury" survives, a meter isn't ditched
89
+ on both sides — the balanced-policy proof is passing while the game is broken.
90
+ Fix the ditches, not the bot.
91
+ - **Unbounded effects.** A card that swings a meter 60 points makes planning
92
+ impossible and the arc a coin flip. Cap |Δ| and assert it.
93
+ - **Ending soup.** Dooms that fire from the wrong meter, or generic "you lost"
94
+ strings, gut the fiction. Attribute each ending to its own edge.
95
+ - **Content that isn't data.** Hand-coded branches can't be linted and rot silently.
96
+ Keep choices in a pure data deck (FUN.md law 7) so editorial checks run in CI.
97
+
98
+ ## Anchors
99
+
100
+ - [[anchor-reigns]] — swipe-choice narrative; meters between two ditches;
101
+ stewardship as the whole verb.
102
+
103
+ ## Verify
104
+
105
+ Prove it against [FUN.md §21 — Narrative decisions](../../docs/FUN.md#21-·-narrative-decisions-reigns-like):
106
+ balanced-policy bot survives; always-left loses 0/20; content lint (unique ids,
107
+ |Δ| ≤ 20, settable flags, no no-ops); every doom fires its own ending; arcs
108
+ terminate both ways. Chrome/menus via `showScreen()`; the card view is `cosmetic`.
109
+
110
+ ## Composes with
111
+
112
+ - [[world-narrative-delivery]] — the story is delivered through choices; this genre
113
+ is its purest engine.
114
+ - [[system-economy]] — treat meters as currencies and the balance problem becomes a
115
+ faucet/sink problem.
116
+ - [[pattern-feedback-loops]] — inter-meter loops author the death spiral and the
117
+ comeback.
118
+
119
+ ## See also
120
+
121
+ - [`docs/FUN.md`](../../docs/FUN.md) §21 — the content-lint recipe in full.
122
+ - [[world-narrative-delivery]] — techniques for telling story with little text.
@@ -0,0 +1,124 @@
1
+ ---
2
+ id: genre-physics-arcade
3
+ title: Physics Arcade
4
+ kind: genre
5
+ tags: [physics, arcade, breakout, peggle, pinball, bounce, aim, swept-collision]
6
+ summary: Trustworthy flight — aim, launch, watch a ball obey clean physics; maximal juice on one trivial input.
7
+ use-when: The design is a launch-and-watch bouncer (Breakout/Peggle/pinball): one aim, deterministic flight, spectacle on impact.
8
+ composes-with: [genre-tower-defense, system-reward-schedules, system-build-diversity, pattern-juice-choreography, pattern-risk-reward, pattern-pacing-and-tension]
9
+ anchors: [anchor-peggle, anchor-tetris]
10
+ verify-with: docs/FUN.md#19-·-physics-arcade-breakoutpeggle
11
+ ---
12
+
13
+ # Physics Arcade
14
+
15
+ **What it is.** You aim one launcher, release, and a ball obeys clean, predictable
16
+ physics — bouncing off pegs, bricks, bumpers, walls — while you watch it pay off.
17
+ Input is trivial (an angle, a power); the depth is in *reading the table* and the
18
+ delight is in the cascade you set in motion.
19
+
20
+ **Player fantasy.** *"I called that shot."* The satisfaction of a bank-shot you
21
+ planned plus the slot-machine thrill of a ricochet you didn't — cause you own,
22
+ consequence the physics authors.
23
+
24
+ ## Pillars
25
+
26
+ 1. **Trustworthy flight.** The ball never tunnels, never teleports, never cheats.
27
+ Swept collision (closed-form time-of-impact) makes the table *readable* — you
28
+ can plan a bank shot because the sim will honour it.
29
+ 2. **Big reward on tiny input.** One angle, maximal spectacle. The juice budget is
30
+ the game; a plain input earns a disproportionate light-and-sound payoff.
31
+ 3. **Legible table.** Every peg, bumper, and multiplier tells you what it does
32
+ *before* you fire. The board is a puzzle you solve with an aim.
33
+
34
+ ## The loop stack
35
+
36
+ | Scale | The beat |
37
+ |---|---|
38
+ | **Moment** | Nudge the aim; the trajectory preview updates; commit. |
39
+ | **Encounter** | One launch → a chain of bounces → clears + score, resolved and choreographed. |
40
+ | **Session** | A board (all targets) or a run of boards; ball budget as the fail clock. |
41
+ | **Meta** | Unlocked launchers/balls/perks; high-score chase; new table layouts. |
42
+
43
+ ## Essential systems
44
+
45
+ | System | Why it's load-bearing |
46
+ |---|---|
47
+ | [[system-reward-schedules]] | The variable-ratio ricochet is the genre's dopamine engine; tune the payoff curve. |
48
+ | [[pattern-juice-choreography]] | Impact feedback (hitstop, particles, pitch-rising combo) *is* the product. |
49
+ | [[pattern-risk-reward]] | The greedy multiplier peg guarded behind a hard bank; last-ball pressure. |
50
+ | [[system-build-diversity]] | Optional: launchers/balls/perks that change how the table plays. |
51
+ | [[system-progression]] | Board-to-board unlocks; score thresholds that gate the next table. |
52
+
53
+ ## Content & difficulty model
54
+
55
+ - **Layout is the level.** Difficulty is peg geometry, not ball speed — a tight
56
+ cluster behind a wall, a lone multiplier in a corner. Author boards, not stats.
57
+ - **Ball budget is the fail clock.** Fewer balls, tighter clears. Grace = an extra
58
+ ball earned by a bucket catch or a full-clear bonus.
59
+ - **Prove winnability with the aim-search bot.** Clone the world, fire candidate
60
+ aims, count clears. This is both your "is the board beatable?" gate and a
61
+ difficulty meter — a board only one aim clears is a spike.
62
+ - **Energy honesty is a fairness rail.** A bounce never leaves the ball faster than
63
+ it arrived; a conservation check catches physics bugs that masquerade as
64
+ liveliness (see FUN.md §19).
65
+ - **Ramp by geometry, then by budget.** Early boards teach one bank; later boards
66
+ chain them and starve the ball count. The aim-search bot's clear-count per board
67
+ is your ramp read-out — plot it, look for cliffs, smooth them.
68
+ - **Skill delta is measurable.** The planned-aim bot must clear boards a
69
+ random-aim bot can't (FUN.md law 2). If firing blind competes with aiming, the
70
+ table has no puzzle — the depth is fake and the juice is doing all the work.
71
+
72
+ ## Signature-mechanic seeds
73
+
74
+ - **Peggle *but* every peg you leave alive fires back next turn** — the table is an
75
+ enemy that reloads (constraint + mechanic-swap; composes [[genre-tower-defense]]).
76
+ - **Breakout *but* the paddle is gravity** — you tilt the whole table instead of
77
+ moving a bar (perspective; the input becomes a field, not a position).
78
+ - **Pinball *but* the flippers cost mana you bank from clears** — economy on the
79
+ twitchiest genre (mechanic-swap; composes [[system-economy]]).
80
+ - **Peggle *but* co-op, one aims and one nudges the table mid-flight** (structure;
81
+ composes [[system-coop-and-competition]], [[genre-coop-chaos]]).
82
+ - **Breakout *but* the bricks are a deck you drafted** — layout as loadout (structure;
83
+ composes [[genre-deckbuilder]]).
84
+
85
+ ## Common pitfalls
86
+
87
+ - **Substep-and-pray collision.** Discrete steps tunnel the ball through thin walls
88
+ at speed; the shot the player trusted fails invisibly. Use swept TOI — the table
89
+ stops being trustworthy the first time a bank shot lies.
90
+ - **Difficulty via ball speed.** Faster balls read as *unfair*, not *harder*. Make
91
+ it harder with geometry and budget.
92
+ - **Juice with no sim consequence.** Screen-shake on every peg dilutes the payoff;
93
+ reserve the big choreography for multipliers and clears (the 2-senses contract).
94
+ - **RNG that isn't yours.** Deflection randomness must run through `world.rng` or
95
+ goldens and shot-planning bots break (FUN.md law 7).
96
+ - **No breather.** A wall of trick-shot boards with no easy clear exhausts; pace a
97
+ gimme board after a spike so the reward loop can reset (see [[pattern-pacing-and-tension]]).
98
+
99
+ ## Anchors
100
+
101
+ - [[anchor-peggle]] — variable-ratio reward + maximal juice on a trivial input; the
102
+ canonical "big payoff, tiny action" loop.
103
+ - [[anchor-tetris]] — the discipline of one perfectly-tuned verb; borrow its
104
+ restraint, not its board.
105
+
106
+ ## Verify
107
+
108
+ Prove it against [FUN.md §19 — Physics arcade](../../docs/FUN.md#19-·-physics-arcade-breakoutpeggle):
109
+ swept-collision no-tunnel proof (24k px/s + 1px-graze-misses), energy invariant,
110
+ aim-search bot clears within the ball budget, golden run. See
111
+ [`sandboxes/physics-lab`](../../sandboxes/physics-lab) for the collision primitive
112
+ in isolation.
113
+
114
+ ## Composes with
115
+
116
+ - [[genre-tower-defense]] — coverage geometry and "counter by placement" transfer
117
+ when pegs fight back.
118
+ - [[pattern-juice-choreography]] — this genre lives or dies on impact feel.
119
+ - [[system-reward-schedules]] — the ricochet is a variable-ratio drop; tune it ethically.
120
+
121
+ ## See also
122
+
123
+ - [`docs/JUICE.md`](../../docs/JUICE.md) — the feel gates for impact choreography.
124
+ - [`sandboxes/physics-lab`](../../sandboxes/physics-lab) · [`sandboxes/juice-lab`](../../sandboxes/juice-lab) — the parts, wired.
@@ -0,0 +1,127 @@
1
+ ---
2
+ id: genre-precision-platformer
3
+ title: Precision Platformer (Celeste-like)
4
+ kind: genre
5
+ tags: [platformer, precision, celeste, movement, grace, dash, coyote, feel]
6
+ summary: Trust in inputs — a movement envelope so honest that every death is the player's own, and the retry is instant enough to make failure fuel.
7
+ use-when: Designing a tight single-screen platformer where mastery of one movement verb is the whole game.
8
+ composes-with: [system-grace, system-onboarding, system-difficulty-and-dda, system-save-and-checkpoint, system-collectibles]
9
+ anchors: [anchor-celeste]
10
+ verify-with: docs/FUN.md#2--precision-platformer-celeste-like
11
+ ---
12
+
13
+ # Precision Platformer (Celeste-like)
14
+
15
+ **What it is.** A character, a jump, usually one signature air-verb (dash,
16
+ grapple, double-jump), and rooms built exactly to the edge of what that verb can
17
+ do. Death is cheap; the room is the puzzle; your *hands* are the solution.
18
+
19
+ **Player fantasy / why it's fun.** *"That was me."* The screen fills with your
20
+ corpses and then you thread the room clean, and the difference was skill you can
21
+ feel yourself having grown. The controls never betray you, so every failure is a
22
+ lesson you accept.
23
+
24
+ ## Pillars
25
+
26
+ 1. **The controls are trustworthy.** Inputs land on the frame you press them.
27
+ Coyote time, jump buffering, corner correction — the [[system-grace]] canon
28
+ makes the character do what you *meant*. Deaths are never the game's fault.
29
+ 2. **Death is free.** Instant respawn, at the room's mouth, momentum unbroken.
30
+ Retry friction is the enemy of flow. (Corpus: CLAWSTRIKE sells itself on
31
+ "each retry is instant, keeping the momentum alive.")
32
+ 3. **The room is a sentence.** Each screen states one idea in your verb's
33
+ vocabulary and asks you to say it back cleanly. Rooms compose ideas; they
34
+ never pad.
35
+
36
+ ## The loop stack
37
+
38
+ | Scale | The loop |
39
+ |---|---|
40
+ | **Moment** | Jump/dash across one gap. Land or die. Sub-second. |
41
+ | **Encounter** | One room (screen): read the layout → attempt → die → adjust one input → thread it clean. |
42
+ | **Session** | A chapter of ~20–40 rooms sharing a movement idea, ending on a room that combines them all. |
43
+ | **Meta** | Optional B-side rooms, hidden collectibles, deathless-run and speedrun goals — the ceiling for players who own the floor. |
44
+
45
+ ## Essential systems
46
+
47
+ | System | Why it's needed |
48
+ |---|---|
49
+ | [[system-grace]] | The genre's spine. Coyote/buffer/corner-correction/variable-height are ~15 unit tests, not vibes (FUN.md law 5). Spec every window in frames. |
50
+ | [[system-onboarding]] | Teach the verb by *safe* rooms first — a dash over a pit you can't fall out of — before the verb is load-bearing over a spike. |
51
+ | [[system-difficulty-and-dda]] | The chapter is the curve; assist mode (slower time, invincibility, air-dashes) extends the audience without touching the core (see Celeste). |
52
+ | [[system-save-and-checkpoint]] | Per-room respawn is the checkpoint; deaths must never rewind more than the current room. |
53
+ | [[system-collectibles]] | Optional off-path collectibles give the skilled a reason to master rooms twice. |
54
+
55
+ ## Content & difficulty model
56
+
57
+ - **Derive the room from the envelope, never eyeball it.** Compute
58
+ `jumpDistance` / `dashJumpDistance` from the actual config *first*; a gap that's
59
+ one pixel past the dash isn't hard, it's broken. Leave human slack — a
60
+ frame-perfect gap is a bug. See [`recipes/platformer-feel.md`](../../recipes/platformer-feel.md)
61
+ for the movement-envelope recipe and [FUN.md law 3](../../docs/FUN.md#part-1--universal-laws).
62
+ - **One idea per room, then combine.** Room introduces "dash *up*," next room
63
+ "dash up into a wall-slide," boss room chains four ideas at speed.
64
+ - **Difficulty = execution length between checkpoints, not gap tightness.** A
65
+ long clean sequence is harder than one brutal jump; scale by *how many* honest
66
+ inputs in a row, not by shaving pixels.
67
+ - **Momentum must survive flight.** Split air-acceleration from air-friction so
68
+ inherited speed carries; a dash off a moving lift should feel like the lift gave
69
+ it to you (FUN.md §2).
70
+
71
+ Reference wiring: [`examples/updrift`](../../examples/updrift) — the golden
72
+ platformer-feel reference; [`examples/kintsugi`](../../examples/kintsugi) — how
73
+ five abilities extend the movement envelope; [`examples/shard-ascent`](../../examples/shard-ascent) —
74
+ the reactive waypoint bot pattern that proves every room 0-deaths.
75
+
76
+ ## Signature-mechanic seeds
77
+
78
+ "X but Y" ([[process-the-twist]]) — bend the *verb* or the *cost of death*.
79
+
80
+ - **Celeste but you keep one echo of your last run** — a ghost replays your prior
81
+ attempt and you must not touch it. (mechanic-swap)
82
+ - **Celeste but the dash paints the platform it lands on** — traversal builds the
83
+ level for a second lap. (mechanic-swap)
84
+ - **Celeste but momentum never resets** — no braking; the room is solved by
85
+ *shedding* speed, not adding it. (constraint)
86
+ - **Celeste but death rewinds time three seconds** — failure is a scrub, not a
87
+ respawn; you re-enter your own recent past. (structure)
88
+ - **Celeste but two characters, one jump button** — mirrored twins share input;
89
+ the room resolves only when both survive. (constraint)
90
+
91
+ ## Common pitfalls
92
+
93
+ - **Untrustworthy input.** No coyote/buffer/corner-correction → the player blames
94
+ the game, correctly. This is the one non-negotiable; ship the grace canon or
95
+ don't ship. [[system-grace]].
96
+ - **Retry friction.** A death animation, a fade, a "you died" screen — each one
97
+ bleeds flow. Respawn on the next frame.
98
+ - **Difficulty by pixel-shaving.** Frame-perfect gaps read as unfair. Depth comes
99
+ from *sequences*, not from tolerances.
100
+ - **Momentum amnesia.** Flight that discards inherited speed makes dashes feel
101
+ dead. Preserve it (FUN.md §2).
102
+ - **Verb creep.** Adding a fourth air-move dilutes mastery of the first. One
103
+ signature verb, deeply explored, beats four shallow ones.
104
+
105
+ ## Anchors
106
+
107
+ - [[anchor-celeste]] — the precision platformer *and* the humaneness of assist
108
+ mode; grace as a first-class system, not polish.
109
+
110
+ ## Verify
111
+
112
+ Prove it with **[FUN.md §2 · Precision platformer](../../docs/FUN.md#2--precision-platformer-celeste-like)** —
113
+ waypoint bot beats every room 0-deaths; movement-envelope inequalities asserted
114
+ against config; grace windows tested edge-in/edge-out. Design the feel here; prove
115
+ the trust there.
116
+
117
+ ## Composes with
118
+
119
+ - [[system-grace]] — the load-bearing system; the pillar-1 promise made mechanical.
120
+ - [[pattern-mastery-and-flow]] — the retry loop lives or dies on flow.
121
+ - [[pattern-anti-frustration]] — free death is the whole forgiveness contract.
122
+
123
+ ## See also
124
+
125
+ - [`recipes/platformer-feel.md`](../../recipes/platformer-feel.md) — the movement-feel recipe.
126
+ - [`examples/updrift`](../../examples/updrift) — the golden feel reference.
127
+ - [`docs/FUN.md §2`](../../docs/FUN.md#2--precision-platformer-celeste-like) — the proof playbook.
@@ -0,0 +1,126 @@
1
+ ---
2
+ id: genre-racing
3
+ title: Racing
4
+ kind: genre
5
+ tags: [racing, driving, top-down, understeer, braking, line, checkpoint, laps]
6
+ summary: The speed/line tradeoff made physical — brake to hold the line or floor it and drift wide; the racing line is the skill.
7
+ use-when: The design is a top-down/arcade racer where cornering is a real physics tradeoff and lap time is the score.
8
+ composes-with: [system-enemy-ai, system-difficulty-and-dda, system-progression, pattern-mastery-and-flow, pattern-risk-reward, pattern-pacing-and-tension]
9
+ anchors: []
10
+ verify-with: docs/FUN.md#20-·-top-down-racing
11
+ ---
12
+
13
+ # Racing
14
+
15
+ **What it is.** You drive a line through corners where speed and control genuinely
16
+ trade off — flooring it understeers you wide, braking tucks you tight. The whole
17
+ game is finding and holding the fast line lap after lap, usually against rivals.
18
+
19
+ **Player fantasy.** *"I found the perfect line."* Mastery you can feel in your
20
+ thumbs: the corner you used to blow now flows, and the clock proves it.
21
+
22
+ ## Pillars
23
+
24
+ 1. **The speed/line tradeoff is physical.** Turn authority *falls* with speed
25
+ (understeer), not grip that magically holds — so flat-out must NOT make every
26
+ bend. Braking is the skill the genre sells; make it a dedicated control.
27
+ 2. **The clock never lies.** Lap time is the honest, legible score. Every tenth is
28
+ a decision you made three corners ago. Ghosts and rivals externalise it.
29
+ 3. **The track is the level.** Corner radius, track width, and sequence author the
30
+ difficulty. Design the geometry against the car's turn radius, not by vibes.
31
+
32
+ ## The loop stack
33
+
34
+ | Scale | The beat |
35
+ |---|---|
36
+ | **Moment** | Brake point → apex → throttle out; one corner, committed. |
37
+ | **Encounter** | A lap: chain corners into a rhythm, defend/overtake a rival. |
38
+ | **Session** | A race or time-trial; the grand prix; podium or PB. |
39
+ | **Meta** | Unlocked tracks/cars/tuning; championship standings; leaderboard chase. |
40
+
41
+ ## Essential systems
42
+
43
+ | System | Why it's load-bearing |
44
+ |---|---|
45
+ | [[system-enemy-ai]] | The rival `driveLine()` is difficulty dial, completability proof, and skill-delta meter in one. |
46
+ | [[system-difficulty-and-dda]] | Rubber-banding, assist braking, racing-line guides — the ramp for a wide skill range. |
47
+ | [[pattern-mastery-and-flow]] | The corner you now flow through *is* the flow channel; the genre is a mastery curve. |
48
+ | [[system-progression]] | Track/car unlocks; tuning as a shallow build layer. |
49
+ | [[pattern-risk-reward]] | Late braking, cutting the kerb, the overtake into a blind corner. |
50
+
51
+ ## Content & difficulty model
52
+
53
+ - **Derive geometry from the car, not the other way.** The inequality chain: turn
54
+ radius (speed ÷ steer-authority) < corner radius < track width. State it as a
55
+ comment and assert it against the actual track and config (FUN.md law 3, §20).
56
+ - **Ordered checkpoints are the entire anti-cheat.** Only the NEXT checkpoint
57
+ counts; cutting the track advances nothing. This single rule replaces a
58
+ collision-fence forest.
59
+ - **Off-track has a speed cap**, not a wall — punish the sloppy line without a
60
+ hard stop that reads as unfair.
61
+ - **The rival is your difficulty dial.** One good `driveLine()` at scalable pace
62
+ gives you completability proof (it finishes) and a skill-delta meter (a braking
63
+ line beats a flooring line: 26.2s vs 27.7s in the campaign).
64
+ - **Track sequence is a tension curve.** Alternate a technical corner-cluster with a
65
+ flat-out straight so the player exhales; a circuit of nothing but hairpins reads
66
+ as punishment, not mastery (see [[pattern-pacing-and-tension]]).
67
+ - **A ghost is the gentlest teacher.** Racing your own PB (or the rival's line)
68
+ externalises the ideal line without a tutorial pop-up — onboarding by contrast.
69
+
70
+ ## Signature-mechanic seeds
71
+
72
+ - **Top-down racer *but* the track is drawn behind you and erased ahead** — commit
73
+ to a line you can't preview (constraint; composes [[system-procgen-design]]).
74
+ - **Racing *but* braking recharges a boost you spend on straights** — the tradeoff
75
+ becomes an economy, not just a physics fact (mechanic-swap; [[system-economy]]).
76
+ - **Racing *but* every rival remembers how you overtook them and blocks it next
77
+ lap** (mechanic-swap + emergence; composes [[system-emergent-systems]]).
78
+ - **Racing *but* one screen, no scroll — the whole circuit visible, you optimise
79
+ the global line** (perspective/constraint).
80
+ - **Racing *but* cargo shifts your mass and turn radius as you deliver it** — the
81
+ car changes under you mid-race (mechanic-swap).
82
+
83
+ ## Common pitfalls
84
+
85
+ - **Grip instead of understeer.** If more speed just means "more traction needed,"
86
+ flat-out beats braking and the whole genre collapses. Authority must fall with
87
+ speed; assert flat-out fails a real corner.
88
+ - **No dedicated brake.** Braking-as-absence-of-throttle robs the player of the
89
+ skill expression the genre is built on. Bind brake to its own key (corpus:
90
+ WitchCup1276, DR1V3N WILD both do).
91
+ - **Rubber-band that erases skill.** DDA that pulls rivals to your bumper regardless
92
+ of your line makes lap time meaningless. Band the *field*, not the outcome.
93
+ - **Wall-collision anti-cheat.** Fencing every shortcut is brittle; ordered
94
+ checkpoints make cutting simply not count.
95
+ - **Wall-clock timing.** Lap timing and physics must step on sim time, not
96
+ `Date.now`, or the golden grand prix and PB ghosts drift (FUN.md law 6).
97
+
98
+ ## Anchors
99
+
100
+ *(No dedicated anchor module yet.)* Borrow structure from [[anchor-tetris]] for the
101
+ "one tuned verb, endless mastery" discipline, and from [[anchor-into-the-breach]]
102
+ for perfect-information honesty if you telegraph rival intent. Corpus references:
103
+ WitchCup1276 (2023 gameplay #10), DR1V3N WILD (2024 gameplay #3).
104
+
105
+ ## Verify
106
+
107
+ Prove it against [FUN.md §20 — Top-down racing](../../docs/FUN.md#20-·-top-down-racing):
108
+ the `driveLine()` bot finishes laps; braking beats flooring (skill delta); cutting
109
+ advances nothing; off-track speed cap holds; golden grand prix. See
110
+ [`sandboxes/physics-lab`](../../sandboxes/physics-lab) for the vehicle-physics
111
+ primitives and [`sandboxes/pathfinding-demo`](../../sandboxes/pathfinding-demo) for
112
+ the racing-line follower.
113
+
114
+ ## Composes with
115
+
116
+ - [[system-enemy-ai]] — the rival driver is the beating heart of both difficulty
117
+ and proof.
118
+ - [[pattern-mastery-and-flow]] — cornering mastery is the flow channel; pace the
119
+ track to keep the player in it.
120
+ - [[system-difficulty-and-dda]] — assist braking and line guides widen the audience.
121
+
122
+ ## See also
123
+
124
+ - [`docs/FUN.md`](../../docs/FUN.md) law 3 — derive the turn-radius inequality
125
+ before you lay a single corner.
126
+ - [`sandboxes/physics-lab`](../../sandboxes/physics-lab) — the car, in isolation.
@@ -0,0 +1,125 @@
1
+ ---
2
+ id: genre-rhythm
3
+ title: Rhythm
4
+ kind: genre
5
+ tags: [rhythm, beat, timing, window, bpm, frame-exact, music, tempo]
6
+ summary: Beat-locked timing game where the beat IS sim time and fairness is three frame-exact assertions — tight but fair.
7
+ use-when: Designing a rhythm/beat game where inputs must land in frame-honest windows and the music is an observer of the beat clock.
8
+ composes-with: [pattern-juice-choreography, system-grace, system-difficulty-and-dda, system-onboarding]
9
+ anchors: [anchor-tetris, anchor-peggle]
10
+ verify-with: docs/FUN.md#18--rhythm
11
+ ---
12
+
13
+ # Rhythm
14
+
15
+ **What it is.** Actions that only count on the beat. A clock ticks in musical time; you
16
+ press inside a window around each beat, and the world answers in tempo. Whether it's
17
+ tap-the-note, move-on-beat, or fight-on-beat, the game is a legality filter over time:
18
+ right thing, right frame.
19
+
20
+ **Player fantasy / why it's fun.** *"I'm locked into the groove and the game is moving
21
+ with me."* The pull is embodied precision — the satisfaction of a press that lands
22
+ exactly, the whole system pulsing in time. Fun is **tight but fair**: a window narrow
23
+ enough to demand mastery, honest enough that a miss is always yours.
24
+
25
+ ## Pillars
26
+
27
+ 1. **The beat is sim time.** Pick a BPM so **one beat is an integer frame count**. The
28
+ sim advances on the beat counter; audio is an *observer* that schedules sound off
29
+ that counter. Never the reverse — audio-driven timing is unprovable and drifts.
30
+ 2. **Fairness is frame-exact.** Three assertions define the whole feel: the input is
31
+ accepted at the **window edge**, refused at **edge+1**, and **hammering acts once**.
32
+ If those three hold, the game is fair; if any fails, it's a lie you can feel.
33
+ 3. **Rhythm is a filter over a turn-based game.** Underneath the beat is a discrete
34
+ turn system; the rhythm layer is a thin input-legality gate (~30 lines over a
35
+ roguelike). Design the turn game first, then constrain *when* moves are legal.
36
+
37
+ ## The loop stack
38
+
39
+ | Layer | The beat |
40
+ |---|---|
41
+ | **Moment** | Hit the window on the beat → the action fires in tempo. |
42
+ | **Encounter** | A phrase/pattern: a run of beats to nail without breaking the chain. |
43
+ | **Session** | A track/level: sustain accuracy from start to finish. |
44
+ | **Meta** | Song select, difficulty tiers, combo/score mastery, new charts. |
45
+
46
+ ## Essential systems
47
+
48
+ | System | Why this genre needs it |
49
+ |---|---|
50
+ | [[pattern-juice-choreography]] | Feel IS choreography timed to the beat; every hit's flash/pop must land on the frame the sim fired. |
51
+ | [[system-grace]] | The hit window and input buffer are a grace system — accepted-inside / refused-outside, proven to the frame. |
52
+ | [[system-difficulty-and-dda]] | Difficulty = window width, note density, and tempo; the tuning dials of "tight but fair". |
53
+ | [[system-onboarding]] | Teach the window by doing on a slow, forgiving track before narrowing it. |
54
+ | [[system-mastery-curve]] | The skill ceiling is timing precision; charts must reward tighter play with higher scores. |
55
+ | [[system-procgen-design]] | Charts as content; generate/validate patterns that stay hittable at tempo. |
56
+
57
+ ## Content & difficulty model
58
+
59
+ - **BPM is chosen, not found.** Solve for a BPM where a beat is an integer number of
60
+ frames; every chart is authored on that grid. A non-integer beat makes the window
61
+ jitter and the three frame assertions impossible to state cleanly.
62
+ - **Window honesty is the whole verify.** Assert the edge-in, edge+1-out, and
63
+ hammer-acts-once cases frame-exactly. These three are the genre's mechanical truth —
64
+ state them before charting a single note.
65
+ - **Foes are frozen between beats.** If the underlying turn game has enemies, prove they
66
+ act *only* on their beats — no between-beat movement — or the rhythm read breaks.
67
+ - **Difficulty ramps three dials.** Narrow the window, raise the density, lift the tempo
68
+ — independently, so a chart can be fast-but-forgiving or slow-but-strict. Never make a
69
+ chart "hard" by making the window dishonest.
70
+ - **Hash-identical replay.** A beat-perfect bot must clear, and the same inputs must
71
+ replay to an identical `world.hash()` — the beat clock makes the whole sim reproducible.
72
+
73
+ ## Signature-mechanic seeds
74
+
75
+ - **Rhythm but it's a roguelike — every step is a beat** — move, attack, and dodge only
76
+ on the pulse; the dungeon is a turn game with a metronome (structure; the literal
77
+ "filter over a turn-based game").
78
+ - **Rhythm but you're clearing a match-3 board on tempo** — swaps only register on the
79
+ beat, cascades resolve in time (mechanic-swap; fuses [[genre-match3]]'s cascade with
80
+ the beat clock).
81
+ - **Rhythm but the beat is a duel** — attacks land only on-beat against a telegraphing
82
+ foe; parries are windows (mechanic-swap; a fighting game gated by tempo).
83
+ - **Rhythm but one button, one lane, escalating tempo** — a hard constraint that makes
84
+ pure timing the entire skill (constraint; the [[anchor-tetris]] "one perfect verb" read).
85
+ - **Rhythm but missing isn't failing, it's souring** — off-beat presses detune the music
86
+ instead of ending the run (tonal; forgiveness as feel, pairs with [[system-grace]]).
87
+
88
+ ## Common pitfalls
89
+
90
+ - **Audio-driven timing.** Scheduling the sim off sound makes it drift and unprovable;
91
+ the beat counter drives, audio observes. This inversion is the genre's cardinal sin.
92
+ - **Non-integer beats.** A beat that isn't a whole frame count makes windows jitter and
93
+ the fairness assertions unstateable. Choose the BPM to fix this.
94
+ - **Dishonest windows.** A window that's secretly wider/narrower than shown, or that
95
+ accepts a hammered double-press, feels like a cheat even when the player can't name it.
96
+ - **Between-beat enemy motion.** Foes that drift off the pulse destroy the read; freeze
97
+ them between beats and prove it.
98
+ - **Charts before the clock.** Authoring notes before the frame-exact window is proven
99
+ bakes unfairness into every level. Prove the three assertions first.
100
+
101
+ ## Anchors
102
+
103
+ - [[anchor-tetris]] — the perfectly-tuned single verb and pure endless mastery; the
104
+ reference for the one-button, escalating-tempo bend.
105
+ - [[anchor-peggle]] — maximal juice on a precisely-timed input; the choreography-on-hit
106
+ feel the rhythm genre lives or dies on.
107
+
108
+ ## Verify
109
+
110
+ Beat-perfect bot clears; window honest to the frame; foes provably frozen between
111
+ beats; hash-identical replay → **[docs/FUN.md §18 · Rhythm](../../docs/FUN.md#18--rhythm)**.
112
+ Design the beat grid and turn game here; prove the three frame assertions there.
113
+
114
+ ## Composes with
115
+
116
+ - [[pattern-juice-choreography]] — the on-beat feel; every hit choreographed to sim time.
117
+ - [[system-grace]] — the hit window as a frame-exact grace system.
118
+ - [[system-difficulty-and-dda]] — window/density/tempo as the difficulty dials.
119
+
120
+ ## See also
121
+
122
+ - [docs/FUN.md §18](../../docs/FUN.md#18--rhythm) — mechanical truth + verify recipe.
123
+ - [docs/JUICE.md](../../docs/JUICE.md) — feel gates for the on-beat choreography.
124
+ - [`sandboxes/`](../../sandboxes/) — reach for the tweens/timing lab to prove a
125
+ window frame-exactly before charting.