Template for a Game using the awesome Bevy engine featuring out of the box builds for Windows, Linux, macOS, Web (Wasm), Android, and iOS.
- small example "game"
- easy setup for running the web build using trunk (
trunk serve) - run the native version with
cargo run - workflow for GitHub actions creating releases for Windows, Linux, macOS, and Web (Wasm) ready for distribution
- the same workflow creates development builds for the mobile platforms (two separate workflows can push to the stores after some setup)
- push a tag in the form of
v[0-9]+.[0-9]+.[0-9]+*(e.g.v1.1.42) to trigger the flow
- CI workflow that checks your application on all native platforms on every push
WARNING: if you work in a private repository, please be aware that macOS and Windows runners cost more build minutes. For public repositories the workflow runners are free!
- Click "Use this template" on the repository's page
- Look for
ToDoto use your own game name everywhere - Update the icons as described below
- Start coding 🎉
- Start the native app:
cargo run - Start the web build:
trunk serve- requires trunk:
cargo install --locked trunk - requires
wasm32-unknown-unknowntarget:rustup target add wasm32-unknown-unknown - this will serve your app on
8080and automatically rebuild + reload it after code changes
- requires trunk:
- Start the android app:
cargo apk run -p mobile- requires following the instructions in the bevy example readme for android setup
- Start the iOS app (see the bevy example readme for ios setup instructions)
- Install Xcode through the app store
- Launch Xcode and install the iOS simulator (check the box upon first start, or install it through
Preferences > Platformslater) - Install the iOS and iOS simulator Rust targets with
rustup target add aarch64-apple-ios x86_64-apple-ios aarch64-apple-ios-sim - run
make runinside the/mobiledirectory
- Start the native app:
You should keep the credits directory up to date. The release workflow automatically includes the directory in every build.
- Replace
build/macos/icon_1024x1024.pngwith a1024times1024pixel png icon and runcreate_icns.shorcreate_icns_linux.shif you use linux (make sure to run the script inside thebuild/macosdirectory) - Note:create_icns.shrequires a mac, andcreate_icns_linux.shrequires imagemagick and png2icns - Replace
build/windows/icon.ico(used for windows executable and as favicon for the web-builds)- You can create an
.icofile for windows by following these steps:- Open
macos/AppIcon.iconset/icon_256x256.pngin Gimp - Select the
File > Export Asmenu item. - Change the file extension to
.ico(or clickSelect File Type (By Extension)and selectMicrosoft Windows Icon) - Save as
build/windows/icon.ico
- Open
- You can create an
- Replace
build/android/res/mipmap-mdpi/icon.pngwithmacos/AppIcon.iconset/icon_256x256.png, but rename it toicon.png
- Trigger the
deploy-github-pageworkflow - Activate GitHub pages for your repository
- Source from the
gh-pagesbranch (created by the just executed action)
- Source from the
- After a few minutes your game is live at
http://username.github.io/repository
To deploy newer versions, just run the deploy-github-page workflow again.
For general info on mobile support, you can take a look at one of my blog posts about mobile development with Bevy which is relevant to the current setup.
Currently, cargo-apk is used to run the development app. But APKs can no longer be published in the store and cargo-apk cannot produce the required AAB. This is why there is setup for two android related tools. In mobile/Cargo.toml, the package.metadata.android section configures cargo-apk while mobile/manifest.yaml configures a custom fork of xbuild which is used in the release-android-google-play workflow to create an AAB.
There is a post about how to set up the android release workflow on my blog.
The setup is pretty much what Bevy does for the mobile example.
There is a post about how to set up the iOS release workflow on my blog.
If you don't want to target Android or iOS, you can just delete the /mobile, /build/android, and /build/ios directories.
Then delete the [workspace] section from Cargo.toml.
nixgl is only used on non-NixOS Linux systems;
when running there we need to use the --impure flag:
nix develop --impure
If using nixgl, then .e.g. gl cargo run, other use
cargo as usual.
You should check out the Bevy website for links to resources and the Bevy Cheat Book for a bunch of helpful documentation and examples. I can also recommend the official Bevy Discord server for keeping up to date with the development and getting help from other Bevy users.
Audio in web-builds can have issues in some browsers. This seems to be a general performance issue and not due to the audio itself (see bevy_kira_audio/#9).
This project is licensed under CC0 1.0 Universal except some content of assets and the Bevy icons in the build directory (see Credits). Go crazy and feel free to show me whatever you build with this (@nikl_me / @nikl_me@mastodon.online ).