TITLE=Bevy ROUTE=/platforms/bevy LOCALE=en MODIFIED=1792476547 URL=https://wiki.teletypegames.org/platforms/bevy L=1 https://bevyengine.org/learn/quick-start/introduction/ L=2 https://bevyengine.org/examples/ L=3 https://bevy-cheatbook.github.io/ L=4 https://bevyengine.org/learn/quick-start/getting-started/ecs/ L=5 https://bevy-cheatbook.github.io/platforms/wasm.html L=6 https://git.teletypegames.org/build/bevy-tools L=7 https://git.teletypegames.org/demos/bevy-demo L=8 #58 Bevy is an open source, data-driven game engine written in Rust. State lives in components, and plain Rust functions ("systems") run over them in parallel — this is ECS. There is no visual editor: a project is a Cargo crate, which fits a Makefile + CI workflow well. WebAssembly is first-class, so the same code runs natively and in the browser. bWebsite:0 https://bevyengine.org 1Tutorials 1═════════ • 1iThe Bevy Book — Getting Started • 2iBevy Examples • 3iUnofficial Bevy Cheat Book • 4iBevy ECS explained • 5iDeploying Bevy to the web (WASM) r────────────────────────────────────────────────────────────────────────────── 1Makefile 1════════ Native builds are plain ccargo build0. Web builds target cwasm32-unknown-unknown and run cwasm-bindgen0 for the JS glue. The cindex.html0 shell is downloaded at export time, so every game uses the same loader. Templates are in 6bevy-tools: copy cexample-makefile.make0 to cMakefile0 and set cPROJECT0 to the crate name from cCargo.toml0. bVersion pinning matters.0 The cwasm-bindgen0 CLI and the cwasm-bindgen0 crate must be the same version: p [target.'cfg(target_arch = "wasm32")'.dependencies] p wasm-bindgen = "=0.2.100" Keep cWASM_BINDGEN_VERSION0 in the Makefile in sync. The CI image (cgit.teletypegames.org/build/bevy-builder0) ships the matching CLI — rebuild it with a new c--build-arg WASM_BINDGEN_VERSION0 when you bump. 2Variables 2───────── t┌──────────────────────┬──────────────────────────┬──────────────────────────┐ t│h Variable t│h Description t│h Default t│ t├──────────────────────┼──────────────────────────┼──────────────────────────┤ t│0 cPROJECT0 t│0 Project / crate name t│0 cbevydemo0 t│ t├──────────────────────┼──────────────────────────┼──────────────────────────┤ t│0 cWASM_BINDGEN_VERSION0 t│0 CLI version, must match t│0 c0.2.1000 t│ t│0 t│0 Cargo.toml t│0 t│ t├──────────────────────┼──────────────────────────┼──────────────────────────┤ t│0 cBIN_DIR0 t│0 Native binary t│0 cbin0 t│ t├──────────────────────┼──────────────────────────┼──────────────────────────┤ t│0 cDIST_DIR0 t│0 Exported artifacts t│0 cdist0 t│ t├──────────────────────┼──────────────────────────┼──────────────────────────┤ t│0 cVERSION_FILE0 t│0 Version file for CI t│0 c.version0 t│ t├──────────────────────┼──────────────────────────┼──────────────────────────┤ t│0 cINDEX_HTML_URL0 t│0 HTML shell t│0 bevy-tools t│ t│0 t│0 t│0 cweb/index.html0 t│ t└──────────────────────┴──────────────────────────┴──────────────────────────┘ 2Targets 2─────── p make build # cargo build --release -> bin/$(PROJECT) p make run # cargo run p make wasm # release wasm + wasm-bindgen -> dist/game.js, » p dist/game_bg.wasm p make export VERSION=1.0.0 # wasm + index.html zipped as bevydemo-1.0.0.h» p tml.zip p make watch # rebuild on change under src/ (needs fswatch) p make clean # remove bin/, dist/ and target/ cmake wasm0 needs the target and the CLI: p rustup target add wasm32-unknown-unknown p cargo install wasm-bindgen-cli --version 0.2.100 2VS Code 2─────── Copy cexample-tasks.json0 to c.vscode/tasks.json0. Tasks: bRun0 (default, cCmd+Shift+B0), bBuild & Run0, bBuild WASM0, bMake build0. 2Generated artifacts 2─────────────────── t┌──────────────────────────────────┬─────────────────────────────────────────┐ t│h File t│h Description t│ t├──────────────────────────────────┼─────────────────────────────────────────┤ t│0 cbin/bevydemo0 t│0 Native release binary t│ t├──────────────────────────────────┼─────────────────────────────────────────┤ t│0 cdist/game.js0, cdist/game_bg.wasm0 t│0 wasm-bindgen output (packaged, then t│ t│0 t│0 removed) t│ t├──────────────────────────────────┼─────────────────────────────────────────┤ t│0 cbevydemo-.html.zip0 t│0 Web build t│ t├──────────────────────────────────┼─────────────────────────────────────────┤ t│0 cbevydemo--win-x64.zip0 t│0 Windows build (mingw cross-compile) t│ t├──────────────────────────────────┼─────────────────────────────────────────┤ t│0 cbevydemo--linux-x64.zip0 t│0 Linux build (glibc) t│ t└──────────────────────────────────┴─────────────────────────────────────────┘ 2Requirements 2──────────── Local only: cmake0, cgit0, cjq0, czip0, ccurl0, the Rust toolchain with the cwasm32-unknown-unknown0 target, a matching cwasm-bindgen0 CLI, and cfswatch0 for watch mode. CI images bring their own tools. r────────────────────────────────────────────────────────────────────────────── 1Pipeline 1════════ The pipeline is not in the game repo. Woodpecker asks the update server, and WarpEngine serves the whole config from c/build/config0 (template clib/warp_engine/ci/woodpecker/platforms/bevy/pipeline.yaml.erb0). The repo needs three things: p # .woodpecker.yaml p platform: bevy p name: bevydemo # only when the software name differs from the repo name • cmetadata.json • the capplication_token0 Woodpecker secret: a WarpEngine ApplicationToken with cupdate0 + cupload0 scopes Builder images come from the update server's cci_platforms0 config. On teletypegames.org the builder is cbevy-ttg0: the cbevy-builder0 image with the crates of every TTG Rust project preloaded into the cargo registry, so the build steps no longer download several hundred crates each (a new dependency is still downloaded as usual). The helper steps (version, upload, publish) run in the cci-tools0 image, which has git, jq, curl and zip preinstalled, so they install nothing. Preview the served pipeline: p curl "https://teletypegames.org/build/config?platform=bevy" 2Steps 2───── t┌─────────────┬──────────────────────────────────────────────────────────────┐ t│h Step t│h What it does t│ t├─────────────┼──────────────────────────────────────────────────────────────┤ t│0 1. version t│0 read the version from cmetadata.json0, else the git short t│ t│0 t│0 hash; outside cmain0/cmaster0 prefix it as t│ t│0 t│0 cdev--0 t│ t├─────────────┼──────────────────────────────────────────────────────────────┤ t│0 2. build t│0 in the builder image (cbevy-ttg0 on teletypegames.org): wasm t│ t│0 t│0 build + cwasm-bindgen0, packed as the versioned zip t│ t├─────────────┼──────────────────────────────────────────────────────────────┤ t│0 3. binaries t│0 native linux-x64 (glibc) and win-x64 via mingw t│ t│0 t│0 (cx86_64-pc-windows-gnu0) t│ t├─────────────┼──────────────────────────────────────────────────────────────┤ t│0 4. upload t│0 web zip, binary zips and c-.metadata.json0 via t│ t│0 t│0 cPOST /build/upload0, cX-Update-Secret0 header t│ t├─────────────┼──────────────────────────────────────────────────────────────┤ t│0 5. publish t│0 cPOST /build/publish?platform=bevy0 t│ t└─────────────┴──────────────────────────────────────────────────────────────┘ The builder image is a debian Rust toolchain with the cwasm32-unknown-unknown and cx86_64-pc-windows-gnu0 targets, mingw-w64 and the cwasm-bindgen0 CLI preinstalled, built from cbuilder.Dockerfile0 in bevy-tools. Binary details: • An cassets/0 directory is packaged next to the binary — Bevy loads it at runtime, it is not embedded. • No mac build: darwin cross-compilation needs osxcross, the same planned toolchain as the ebitengine mac targets. • The API registers the c--.zip0 files as cwin_x640 / clinux_x640 release assets. • A cold Bevy release build compiles several hundred crates, so expect a much longer build step than the other engines. 2Demo project 2──────────── 7bevy-demo — animated "TELETYPE GAMES" wave text on Bevy 0.16, the same demo as 8ebitengine-demo.