Skip to main content

Module cutscene

Module cutscene 

Source
Expand description

Cutscene system built on top of the Boa JS engine’s async/await.

Cutscenes are expressed directly as JS async functions — no separate scripting language needed. A cutscene is simply an export async function that uses the existing game.* API (showText, movePlayer, delay, fadeScreen, playSound, etc.).

§Architecture

Trigger / Map Enter
    │
    ▼
CutsceneManager::start_cutscene("prof_lab_intro")
    │  sets active=true, current_script=Some("prof_lab_intro")
    │
    ▼
game loop: sees cutscene active → calls script_engine.call_function("prof_lab_intro")
    │
    ▼
JS: export async function prof_lab_intro() {
      await game.fadeScreen("out");
      await game.showText("Prof: Hello!");
      await game.movePlayer(x, y);
      await game.delay(30);
    }
    │  each await → ScriptCommand → Rust handles → promise resolved → next await
    │
    ▼
function returns → cutscene ends → player regains control

While a cutscene is active, the game loop suspends normal player directional input. Dialog/choice interaction remains functional so that await game.showText() and await game.showChoice() can proceed.

Structs§

CutsceneManager
Manages cutscene execution state.