Interactive tutorials for browser games, written as data. Steps that wait for the player to do something (not just read), highlights that dim everything except the target, steps that freeze the game, read-and-continue steps with a minimum time, stuck detection with a better hint, skip and replay, resuming at the saved step, device-aware text, and drop-off funnels to see where players quit. Test...
Download skill (.zip) Files on GitHubGame tutorial system
Use a scripted tutorial when the game has several systems that must be learned in order (strategy, building, card games). For action games, prefer level design plus hints (game-onboarding) and keep the scripted part under a minute.
assets/tutorial.js
import { createTutorial, funnel } from "./tutorial.js";
const tut = createTutorial({ id: "basics", save, report: (e) => analytics.push(e), onDone: () => (flags.tutorial = true), steps: [
{ id: "move", say: { keys: "Move with WASD", touch: "Drag to move" }, until: (g) => g.moved > 150 },
{ id: "coin", say: "Grab the coin", focus: (g) => g.coin, until: (g) => g.coins > 0, onStart: (g) => g.spawnCoin() },
{ id: "enemy", say: "Jump on the red one!", freeze: false, until: (g) => g.stomped, timeout: 20, hint: "Jump while you're above it" },
{ id: "pause", say: "Press Esc any time to pause", next: "tap", minTime: 1 },
] });
scene.enter: if (!tut.start(game)) startNormally(); // false = already finished earlier
each frame: tut.update(dt, game, input.lastDevice); if (tut.freezing) skip the world update;
if (tut.waitingForTap && input.wasPressed("confirm")) tut.next(); tap on tut.skipRect -> tut.skip(game)
draw (after the HUD): tut.draw(ctx, { width, height }, camera, game)
until: the step finishes when the player does it. Most steps should be like this.focus: returns{ x, y, r }in world units; the default drawing dims the screen around it with a pulsing ring.timeout+hint: after that many seconds, the text changes to the hint and astuckevent is reported.minTime: no step can be skipped through by accident in under 0.4 s (or this value).- Progress is saved per step: closing the game mid-tutorial resumes there.
start(game, { force: true })replays it from a “Replay tutorial” menu item. - Skip is always visible (bottom corner), for players who know this kind of game.
Writing good steps
- One action per step, in the player’s words, under 8 words.
- The step text names the bound key (
controls.label("jump")) and switches for touch. - Spawn what the step needs in
onStart(a coin right there), so there’s nothing to search for. - Let the step finish by doing, even if they didn’t read it.
- End with something fun: the first real enemy or level, not a “Tutorial complete” screen.
Drop-off
funnel(events, stepIds) → { steps: [{ step, reached, percent }], donePercent }. A step where many players stop is too
hard or unclear: rewrite it, split it, or cut it.
Tested
Node tests: device text, advancing on the action, minimum time, tap-to-continue steps, stuck hint and event, drawing, resuming at the saved step, not repeating after done, skip, funnel percentages. Used in the UI kit demo (four steps with focus ring and skip).
Pitfalls
Text-only steps, unskippable tutorials, tutorials that restart every time, steps that can’t be completed on touch, freezing the game for every step, and a tutorial for things the level could teach.