jengine-microgame
WarioWare-style microgame compilation - a queue, a countdown, a speed that ramps, and a one-call verdict contract.
| Kind | Project package: linked into the builds of the projects that list it |
| Source | packages/jengine-microgame |
| Version | 0.1.0 |
| Entry point | jengine_microgame::MicrogamePackage |
| Script namespace | Microgame |
| Listed by | projects/arcade-classics |
Using it
Section titled “Using it”List it in the top-level "packages" array of project.jengine:
{ "packages": [ { "name": "jengine-microgame", "source": { "type": "path", "path": "../../packages/jengine-microgame" } } ]}Then rebuild the editor viewport for the project (jengine viewport-build projects/<name>, or the
editor’s Rebuild viewport banner). Native and web builds link it on their own.
A scene that uses its components must be a v2 scene ("version": 2): a v1 scene has no field
for a package component and keeps it as inert custom data.
A script can check that the package is linked with if Microgame == nil then return end.
Components
Section titled “Components”| Scene key | Rust type | |
|---|---|---|
be_stage | Stage | package only: needs a v2 scene |
Script commands
Section titled “Script commands”Commands run in every runtime and return nothing; a package publishes what scripts read onto components (see the notes below). The flat name also works.
| Call | Flat name |
|---|---|
Microgame.resume(e, state) | be_resume |
Microgame.verdict(e, won) | be_verdict |
Microgame.quit(e) | be_quit |
Scenes that use it
Section titled “Scenes that use it”projects/arcade-classics/assets/scenes/be_aim.sceneprojects/arcade-classics/assets/scenes/be_count.sceneprojects/arcade-classics/assets/scenes/be_dodge.sceneprojects/arcade-classics/assets/scenes/be_grab.sceneprojects/arcade-classics/assets/scenes/be_mash.sceneprojects/arcade-classics/assets/scenes/be_wait.sceneprojects/arcade-classics/assets/scenes/errands.scene
From packages/jengine-microgame/src/lib.rs.
Brisk Errands - a WarioWare-style compilation of microgames.
- [
run]: the compilation and one round of it. Pure. - [
content]: the two data tables, and the check that refuses a microgame which cannot be won at the speed the compilation will reach.
Every microgame is a real scene, and that is the point
Section titled “Every microgame is a real scene, and that is the point”This is the arcade’s first test of scene lifecycle at rate. Every other game here loads a scene once and stays in it; this one loads a new scene every three or four seconds, for as long as the player survives.
It earned its keep before a microgame existed. Asking what would break turned up BUGS #149: script timers, event listeners and GUI click handlers survived a scene change in every runtime, and since each carries a raw entity id that the next scene reuses, a two-second timer armed by one microgame fired into the next one. A hundred swaps stranded two hundred timers. Nothing had noticed, because until now nothing churned scenes.
Where the run lives
Section titled “Where the run lives”Not in the world. A scene swap replaces the world, so a compilation that lived in an entity would be destroyed by the thing it is driving.
run::Run is a plain serializable value that rides the save store,
which is the one piece of session state that deliberately survives a swap -
ScriptServices::clear_scene_scoped names it as such, and BUGS #149 is
what happened to the pieces that were not meant to. The script reads it on
load, hands it to the package, and writes back what comes out.
So this package owns every rule, and the script owns exactly the two things
only a script can do: touching the save store, and calling load_scene.
Component ("version": 2 scenes)
Section titled “Component ("version": 2 scenes)”be_stage, on the runner entity of every microgame scene and of the
interstitial that picks the next one.
"be_stage": { "tables": { "games": "data/be_games", "runs": "data/be_runs" }, "game": "dodge", "which": 0}game empty means “this is the interstitial” - it runs no round and only
reports what to load next.
Script commands
Section titled “Script commands”| Call | Does |
|---|---|
Microgame.resume(e, json) | hand the package the saved run (or "" to start one) |
Microgame.verdict(e, won) | the whole microgame contract: won or lost, once |
Microgame.quit(e) | abandon the run |
A microgame that never calls be_verdict loses when its countdown expires,
which is the normal path rather than an error: half of these games are “do
nothing and you lose”.