Skip to content

Publish a Bevy game

All engines

Bevy runs in the browser as WebAssembly. ThrunGames does not detect Bevy, so set the engine yourself.

Build for the web

  1. Add the target: rustup target add wasm32-unknown-unknown.
  2. Build in release mode:
cargo build --release --target wasm32-unknown-unknown
  1. Run wasm-bindgen to make the JavaScript glue. Replace my_game with your crate name. The wasm-bindgen-cli version must match the wasm-bindgen version in your Cargo.lock.
wasm-bindgen --target web --out-dir out target/wasm32-unknown-unknown/release/my_game.wasm

Add index.html and assets

Put an index.html in out. It loads the generated script and starts the game:

<!doctype html>
<html>
  <body>
    <script type="module">
      import init from "./my_game.js";
      init();
    </script>
  </body>
</html>

Copy your assets folder into out too. out is now the export folder, so zip its contents.

Zip and upload

Zip the contents of the export folder, so that index.html is at the root of the zip. Do not zip the folder itself. If index.html ends up inside a folder, the upload fails and tells you so.

Your game has to exist before you upload. If you have not made it yet, sign in, open My games and choose "Add new game". (You need a developer account: see Become a developer.) Note the game's slug, the last part of its address.

Then upload with the ThrunGames CLI:

thrungames login
thrungames upload path/to/export-folder --game <your-game-slug> --version 1.0.0 --width 960 --height 600 --submit

--width and --height are the size of the game's play area in pixels on a Classic game page; an Immersive game fills the screen and ignores them.

The CLI zips the folder for you. You can also point upload at a .zip file you made yourself. Leave out --submit to keep the upload as a draft with a preview link. To skip the flags next time, put a game.json with name, version, width and height in the folder (see the CLI page).

The limits are 450 MB for the zip through the CLI (100 MB on the website), 500 MB unpacked, and 5000 files.

Engine and layout

ThrunGames detects the engine when you upload and sets it on your game if you have not set one. ThrunGames does not detect this engine on its own, so set it yourself. To change it later, use the game settings, or:

thrungames games edit <game> --engine bevy
thrungames games edit <game> --layout classic