Skip to content
Cursor Agent edited this page Nov 29, 2026 · 1 revision

Export

cargo xtask dist packages a game from its build.ron: the name, the first scene, the window, the asset folder, and the game crate when the game has code. The root build.ron is the sandbox. A game from Building Games has games/<name>/build.ron. The long form is docs/WEB.md and chapter 7 of the guide.

Native

cargo xtask dist
cargo xtask dist --manifest platformer.build.ron
cargo xtask dist --manifest games/my-game/build.ron

dist/<name>/ holds the release binary, build.ron, and the assets. Zip that folder. On Windows the binary opens no console and writes the log to log.txt beside it.

The player binary, without packaging, is:

cargo run -p fanalor-player -- assets/scenes/sandbox.ron
fanalor-player [--asset-root DIR] [--title TEXT] [--size WxH] <SCENE>

Web

rustup target add wasm32-unknown-unknown
cargo install wasm-bindgen-cli --version 0.2.126 --locked

cargo xtask dist --web
cargo xtask dist --web --manifest platformer.build.ron
cargo xtask dist --web --manifest games/my-game/build.ron --out target/guide-dist

Install wasm-bindgen-cli at the version of the wasm-bindgen crate in Cargo.lock. 0.2.126 matches current main. cargo xtask dist --web refuses a mismatch and prints the version it wants.

The output is dist/<name>-web/ (the sandbox's folder is dist/Fanalor Sandbox-web/). Four files, and nothing else:

File What it is
index.html The page: a full-window canvas, a status line, the loader
game.js The wasm-bindgen loader
game_bg.wasm The player, or the game's own binary
game.pak build.ron and every asset, fetched once before the game starts

A scene build ships the player, which starts the scene the manifest names. A game with its own binary must start through fanalor_core::when_assets_ready, so it runs after the pack arrives. games/platformer/src/main.rs is the pattern.

Try it:

cd "dist/Fanalor Sandbox-web"
python3 -m http.server 8000

Open http://localhost:8000. Opening index.html from file:// does not work: the page cannot fetch the wasm or the pack.

Upload the four files anywhere that serves static files (GitHub Pages, itch.io with index.html at the zip root, Netlify, a bucket). Serve .wasm as application/wasm when you can. The wasm is on the order of 13 MB, about 4 MB gzipped. WebGPU is only offered on secure pages (https:// or localhost); plain HTTP elsewhere falls back to WebGL2. The build does not use threads, so it does not need cross-origin isolation headers.

The project site's playable samples are this export, assembled by website/assemble.sh. The site itself is fanalor.dev/Fanalor-Engine. Arena's web client can join a native server, and CI does that, but the site does not host a match: a page cannot run arena-server.

What a web build does differently

  • The canvas fills the window. The manifest's window size is a desktop setting.
  • Audio starts on the first key, click, or touch.
  • Saves go to localStorage for that site, one entry per slot.
  • The log is the browser console.
  • There is no hot reload, and no files outside the pack.
  • The network is WebSockets only. No hosting, no LAN discovery. Join ws:// or wss://. See Networking.

Checking a web build

node crates/fanalor-player/web/test/first-frame.mjs
node crates/fanalor-player/web/test/play.mjs

first-frame checks that the sandbox draws, on WebGPU and on WebGL2. play walks the platformer: movement, a coin, sound. Each command builds with cargo xtask dist --web into target/, serves it, and drives it. --skip-build reuses the last build. CI runs these with Node and Playwright.

Clone this wiki locally