Curtain Call: Short Game Frame with Title, Cutscene, Results and Replay
README.md
curtainKit
The whole frame around a short game, from one config call. Every short game (30 seconds to three minutes, played again and again) needs the same frame: a title screen, an opening cutscene, controls on one or two buttons, an ending and a results card with Replay. curtainKit is that frame. Your game only plays: it resets, begins, updates and reports its score and outcome. The kit draws every screen, runs the cutscenes and the transitions, saves the player's bests and makes Replay instant.
local Curtain = require("curtainKit.api")
local game = {}
function game.reset(ctx) --[[ put the world back to the start (behind the curtain) ]] end
function game.begin(ctx) --[[ controls are live, the clock runs ]] end
function game.update(ctx, dt)
if ctx.buttons.primary.pressed then ctx.addScore(10) end
if ctx.time() > 30 then ctx.finish({ outcome = "win", stats = { taps = ctx.getScore() / 10 } }) end
end
-- in the scene entrypoint:
function onLoad()
Curtain.start({
id = "tapDash", title = "Tap Dash", tagline = "Thirty seconds. One button.",
look = "velvet", -- velvet | dusk | paper
buttons = { primary = { label = "Tap", hint = "Tap as fast as you can" } },
opening = { cutscene = { shots = { { dur = 5, pos = { { 0, 8, -20 }, { 0, 3, -8 } }, look = { 0, 1, 0 } } },
subtitles = { { t = 0.5, dur = 4, text = "The clock is already running." } } } },
game = game,
endings = { win = { title = "Done!", line = "Not bad at all." } },
stats = { { key = "taps", label = "Taps", best = "max" } },
grades = { { "S", 2000 }, { "A", 1200 }, { "B", 600 }, { "C", 0 } },
})
end
What a game gets
- Title screen over a live camera: an eyebrow line, the game's name set large with a glow, a tagline, a breathing "Press [Space] to start" (the glyph follows the device: Space, A or Tap), a strip with the player's best score, best grade and runs, a credits line. Behind it,
titleScreen.camera(any cutscene definition) loops slowly with no letterbox. - One opening cutscene, skippable on every device (key, pad, on-screen Skip): the engine's own
cutscene.play, with letterbox, fades and subtitles. Shown once a session; Replay never shows it again (opening.everyRun = trueto change that). - Ready beat: "Ready" then "Go!" punch in (
text.ready,falseto skip), then the game begins. - One or two buttons on every device:
primary(Space, Enter, Z, Up, W, left mouse; pad A, right trigger; a large touch button) and, when the config namesbuttons.secondary,secondary(X, Shift, C, Down, S, right mouse; pad B, left trigger; a second touch button). The game readsctx.buttons.primary.held / .pressed / .released / .heldTime. Pause is Esc / P, pad Start, or the HUD's pause button; the pause map is live only while a run is on screen and stands the app menu down meanwhile, so Escape reaches the pause card (on the title screen it opens the app menu as usual). While the frame runs, its controls stand the scene'splayerinput group down, so a walking avatar does not walk under the game's buttons. - HUD: a score chip that rolls up with "+N" pops, an optional progress bar with a label (
ctx.setProgress(p, "120 m to go")) or timer (ctx.setTimer(secs)), big centre callouts (ctx.callout("GATE x3")), a control hint for the first runs, and the pause button. Safe-area aware. - Ending per outcome:
ctx.finish({ outcome = "win" })picksendings.win(orendings.default): its cutscene (a definition, or a function of the result that builds one, so it can frame where the run ended), a big banner (title,line,color, shownbannerAtseconds in), or a timedholdwhen there is no cutscene. - Results card: the outcome, the score counting up, a NEW BEST ribbon, a grade stamp slammed on the corner (
grades), up to five stat rows with their own BEST tags (stats), "Best 3,240 · Run 7", and Replay (primary) and Title (secondary, or Esc when there is one button). Mouse, touch, keyboard and pad all work. - Pause card: Resume, Restart, Title. The game's
pause(ctx, on)hook is told. - Curtain transitions: two velvet halves and a valance close over the screen, the world resets behind them, and they part again, so Replay is instant and nothing pops.
- Records, per player and saved in their own
runtime_datastore: best score, best grade, runs, wins, the best of every stat markedbest = "max"or"min", and the running total across runs of every stat markedtotal = true. - Unlocks (player progression):
unlockslists rewards earned by a running total ("200 coins over all your runs"), by wins or by a grade. At results the kit checks them against the records; each one newly met is saved, named on an UNLOCKED ribbon on the results card (it slides in after the score count with the new-best sound) and fired as anunlockevent, so the game can hand it out. The title's records strip says what is next: "Next: Jade paper – 120 / 200 fireflies", or "All unlocked". - Sound: ten frame sounds ship with it (confirm, back, curtain, tick, go, score, win, lose, results, newBest);
soundsreplaces any, adds music per state, orsounds = falsesilences the frame. - Three looks, every token overridable:
velvet(theatre crimson and gold),dusk(indigo glass and amber light),paper(cream card, ink and a red stamp).look = { base = "dusk", accent = "#9be3ff" }. - Multiplayer: the frame runs on each player's own machine (screens, cutscenes, records). Two players never drive each other's screens.
The game contract
config.game is a table of hooks, each given the same ctx:
| Hook | When |
|---|---|
reset(ctx) | Behind the closed curtain before every run (and before the title). Put the world back to its start. |
begin(ctx) | The run starts: controls live, clock running. |
update(ctx, dt) | Every frame of the run. |
stop(ctx) | The run ended or was left. |
pause(ctx, on) | Pause opened or closed. |
idle(ctx, dt) | Every frame outside the run (title, ready, ending, results): keep the world alive. |
ctx: buttons, addScore(n, { text?, color?, silent? }), setScore(n), getScore(), setProgress(p?, label?), setTimer(secs?), callout(text, color?), time(), run(), state(), sound(name), unlocked() (the unlocks earned so far, { [id] = order }), finish({ outcome, score?, stats }).
Config fields
id (records key, required), title, tagline, credits, look, buttons (primary, secondary: { label, hint, glyphs = { kbm, gamepad, touch } }), titleScreen ({ camera = cutscene def or function, hidePlayer }), opening ({ cutscene, skippable, letterbox, everyRun }), game (required), endings ({ [outcome] = { title, line, color, cutscene, bannerAt, hold, skippable, letterbox, resultsTitle, resultsLine } }), winOutcomes (default { "win" }), stats ({ { key, label, format = "int" | "time" | "pct" | a format string | function, best = "max" | "min", total = true, always } }; total = true keeps a running sum across runs), unlocks (see below), grades ({ { letter, minScore }, ... } best first, or function(result) -> letter), formatScore, readySeconds, showTitle (false starts straight into a run), hud (false, or { hintSeconds, hintRuns, hintUntilPress }; hintUntilPress = true keeps the control hint up until the player first presses a button), sounds, text (every word: eyebrow, pressPre, pressPost, best, grade, runs, score, newBest, statBest, replay, title, paused, resume, restart, ready, footer, skip, unlocked, nextUnlock, allUnlocked, winWord, winsWord, gradeWord), hooks (state(new, old)), language (force the frame's language, e.g. "pt-BR"; left out, it follows the player), demo (hands-free play, see below).
Words in the player's language
Every word the frame shows comes from the engine's i18n catalogs (guides topics/localization). The kit's own words (prompts, buttons, records strip, results labels, unlock lines, Skip, the key glyphs) ship in curtainKit.package/locales/en|pt-BR/curtain_kit.json. Any text a config gives (title, tagline, credits, text.*, buttons.*.label/hint, endings.*.title/line/resultsTitle/resultsLine, stats[].label, unlocks[].label/desc/unit, ctx.callout, ctx.setProgress labels, ctx.addScore pop text) may be:
- plain text, shown as written (
"Home"); - a key into a catalog your world ships (
"lantern_drift.win_title", read from/zero/source/locales/<tag>/lantern_drift.json); { key = "lantern_drift.to_shrine", values = { metres = 120 } }for{{ placeholders }}(countpicks the plural form);- an
i18n.text(...)value, or a function returning any of these.
Cutscene subtitles take { t, dur, key = "lantern_drift.opening_1" } as well as text. A world's catalog overrides any kit word by stating the same key (curtain_kit.replay). The language follows the player (their choice, ZeroMind's language, their device) and the screens redraw when it changes; language = "pt-BR" or Curtain.setLanguage("pt-BR") forces one for the frame alone without touching the player's own choice. ctx.t(key, values) gives a game the same lookup for its own runtime text.
Demo: recording and attract mode
demo = {
autopilot = function(ctx, dt) return { primary = shouldHold(), secondary = false } end,
titleSeconds = 4, resultsSeconds = 6, -- how long the title and results card hold in a demo
attract = { after = 30 }, -- an idle title plays the demo after 30 s (`attract = true` is 25 s)
},
autopilot is called every frame of a demo run instead of reading real buttons; the frame turns its answers into the usual held / pressed / released edges, so the game's own update runs unchanged. Recording (Curtain.record()): the title for titleSeconds, the opening cutscene in full (not skippable), the run flown by the autopilot, the ending and the results card for resultsSeconds; it ends on the results card, or returns to the title and goes again with loop = true (cycles = n for n passes). Real input is ignored (cancelOnInput = true lets it end the demo). Attract: after attract.after idle seconds on the title, the demo plays without the opening, with a pulsing "DEMO · Press any button to play" chip, and any button or click returns to the title. Demo runs save no records and earn no unlocks (saveRecords = true to change that), do not count as runs, and ctx.demo() names the mode while one plays. Every option can also be passed to Curtain.record(opts) / Curtain.attract(opts), plus language for the recording's language.
Without code: in play, zero curtain record from the shell (or the curtain.record tool) starts a recording; zero curtain record '{"language":"pt-BR","loop":true}', '{"mode":"attract"}', '{"stop":true}'. From Luau it is one line: require("curtainKit.api").record({ language = "pt-BR" }).
Styles: title, results, ending and control prompts
style picks a design per screen; every field is optional and a missing or unknown name keeps the default, so a game that never sets style looks exactly as before. Every style works in all three looks and scales with the canvas.
style = {
title = "poster", -- classic (default) | poster | minimal
results = "ribbon", -- card (default) | ribbon | scoreboard
ending = "stamp", -- banner (default) | stamp | caption
prompt = "keycaps", -- chip (default) | keycaps | ring
controls = "hold", -- hold | tap | twoButton (default: twoButton with a secondary button, else hold)
words = { hold = "Hold", tap = "Tap", press = "Press", start = "Start", firstRun = "Your first run awaits" },
},
- title:
classicis the centred logo, tagline and breathing start line.postersets the title huge and left-aligned, one word a line, over a side shade, with the tagline under an accent bar and a menu panel on the right (a lit Start bar, then Best, Grade, Runs and the next unlock).minimalleaves the shot almost clear: a small, widely tracked wordmark low on screen, one pulsing "Press [Space] to start" line and a best-score chip. - results:
cardis the centred card with the grade stamp on its corner.ribbonis a full-width band across the middle of the screen with the outcome, the counting score and the stats in one row and the grade tile at the end, with the footer and Replay / Title under it.scoreboardfills the screen: the outcome and grade across the top, the score set very large on the left, the stats list on the right, and the footer and buttons along the bottom. - ending:
banneris the title and line in the upper third.stampslams the outcome down in the centre as a big rotated stamp with a shock ring, with the line under it.captionis a cinematic lower third: a small tracked title and the line, low on the left over the letterbox, behind an accent bar. It sits where cutscene subtitles go, so it suits endings without subtitles. - prompt (the HUD's control hint, shown for
hud.hintRunsruns):chipis the pill along the bottom.keycapsputs big 3D key glyphs centred low on screen, pressed in a loop (one long press for hold, a double tap for tap), each with its verb and hint.ringis a radial prompt near the bottom: a segmented ring around the glyph fills clockwise like a hold (or ripples like a tap), with the verb and hint beside it. - controls words and lays out every prompt:
holdshows HOLD,tapshows TAP,twoButtonshows PRESS and draws both buttons, secondary on the left and primary on the right (keycaps side by side; rings in the bottom corners).buttons.primary.verb/buttons.secondary.verboverride the verb per button. Withcontrolsset, thechipprompt gains the verb tag too; without it the chip is unchanged. The scheme changes only the wording and layout: input is still read throughctx.buttons. wordsoverrides the few words the styles add; atextentry of the same name (text.start,text.hold, ...) is used whenwordsdoes not name it. Screens list:require("curtainKit.styles").names().
Unlocks
stats = { { key = "coins", label = "Coins", best = "max", total = true } },
unlocks = {
{ id = "red", label = "Red paper", desc = "Collect 200 coins over all your runs", stat = "coins", total = 200 },
{ id = "gold", label = "Gold paper", wins = 1 }, -- wins counted over all runs
{ id = "crown", label = "Crown", grade = "S" }, -- a best grade of S (or better)
},
Each entry is { id, label, desc?, unit? } plus one condition: stat = key, total = N (the stat's running total reaches N; the stat must say total = true), wins = N, or grade = letter. They are checked at results, after the run is recorded, in config order. A newly met unlock is saved as curtain/<id>/unlocked/<unlockId> (its value is the order it was earned in, 1 first), shown on the results card's UNLOCKED ribbon (with desc when only one is new), plays the newBest sound as the ribbon lands, and fires unlock (def, result). The title shows the first unmet unlock in config order with the player's progress (unit names the count; it defaults to the stat's label in lower case), or text.allUnlocked. Read the set with Curtain.unlocked(id?) or ctx.unlocked() in a hook (reset is the place to apply a cosmetic). Unlocks are local, per player, like every record.
API
Curtain.start(config), stop(), status(), on(event, fn) (state, begin, finish, newBest, unlock (def, result), replay, title, *), replay(), toTitle(), startRun(), setPaused(on), ctx(), records(id), unlocked(id?) ({ [unlockId] = order }; the running game's when no id), looks(), setLanguage(tag?) (force the frame's language; nil follows the player), language() (the tag in force, and whether it is forced), languages() (the kit's catalog languages), record(opts?, config?) (a hands-free recording; returns ok, why-not), attract(opts?) (the attract demo now), stopDemo(toTitle?), demo() ({ mode, cycle, opts } or nil). Events add demo (mode, on, reason) and demoCycle (n). ctx adds t(key, values), language() and demo(). Curtain.records (the module) also has total(id, key), unlockProgress(id, def) and clear(id), which forgets totals and unlocks too.
Parts
| Part | What it does |
|---|---|
api | the front door |
director | the flow, the game's ctx, the curtain, inputs |
screens, looks | every screen as a widget tree; the look tokens |
records | per-player saved bests |
sounds, sfx/ | frame sounds and music; ten default clips |
events | local signals |
controls, controls2, pause | the input maps (primary, secondary, pause during a run) |
CurtainHost | the per-machine host component (spawned for you) |
The kit's world, Curtain Call, plays Lantern Drift, a one-button glide across a lake at dusk, built on curtainKit.
Changelog
-
1.2.1: the paper look lays a soft cream glow behind the classic title's words (look token
titleBacking), so dark ink reads over a bright daylight scene; other looks are unchanged. -
1.2.0: styles (
style = { title, results, ending, prompt, controls }: title classic|poster|minimal, results card|ribbon|scoreboard, ending banner|stamp|caption, prompt chip|keycaps|ring, controls hold|tap|twoButton; defaults unchanged); every player-facing word translatable through i18n catalogs (kit words in English and Brazilian Portuguese, config strings and cutscene subtitles take catalog keys,languageconfig andCurtain.setLanguage); recording and attract modes (Curtain.record,attract,stopDemo, configdemowith an autopilot,zero curtain record); accented letters survive upper-casing; new guide, Build a whole game with curtainKit. -
1.1.6: the ending banner (title and line) sits on a soft dark glow so a light title reads over dark scenery; the dusk results card is nearly opaque so an ending effect does not show through the score.
-
1.1.5: the results grade stamp lands from 1.45x in 0.38 s and is opaque by a third of the way in, so it no longer passes as a large pale disc behind the card.
-
1.1.4: the ending banner's line sits on a soft dark backing with a text shadow, so it reads over a bright ending shot.
-
1.1.3:
hud.hintUntilPresskeeps the control hint on screen until the player first presses a button, for games whose first seconds teach the controls. -
1.1.2: a long outcome title on the results card steps down a size so it clears the grade stamp; the ending banner title carries a dark shadow under its glow so it reads over a bright sky.
-
1.1.1: the results card leaves no empty band between the score and the stats when there is no NEW BEST.
-
1.1.0: player progression. Stats may say
total = truefor a running sum across runs (curtain/<id>/total/<key>);unlocks(by a stat's total, by wins or by a grade) are checked at results, saved, named on an UNLOCKED ribbon on the results card with the new-best sound, and fired as anunlockevent; the title's records strip shows the next unlock and the player's progress toward it;Curtain.unlocked(id?),ctx.unlocked(); newtextwordsunlocked,nextUnlock,allUnlocked,winWord,winsWord,gradeWord. -
1.0.1: the progress bar fill is a real width (it read as full before); score pops stack a step apart and clear on every reset; ending banners sit in the upper third so they clear the subject and a cutscene's subtitles; the results header keeps more room for the grade stamp.
-
1.0.0: first release. Title over a looping live camera, one skippable opening cutscene (once a session), ready beat, one- or two-button input on keyboard, mouse, gamepad and touch, HUD (rolling score, pooled score pops and a progress bar moved by
ui.setMotion, so play never rebuilds the HUD), endings per outcome with their own cutscenes, results card (count-up, NEW BEST, grade stamp, stat rows with BEST tags, Replay / Title), pause card (its map stands the app menu down only during a run), curtain transitions, per-player records, ten synthesized frame sounds, three looks.