This is the Leafwing Studios' template repo, providing a quick, opinionated base for high-quality Bevy game projects (and libraries). We've shaved the yaks for you!
The licenses here are provided for template purposes: this repository itself is provided under MIT-0. Feel free to use, hack and adopt this freely: no attribution needed.
Use this template by pressing the big green "Use this template" button in the top right corner of this repo to create a new repository.
This repository has dynamic linking enabled for much faster incremental compile times.
If you're on Windows, you'll need to use the nightly Rust compiler.
Swap by using rustup default nightly.
You may want to run rustup update afterwards to get your tools up to date.
If you are making a game:
- Enable the features you need from Bevy in
Cargo.toml. - Delete the
examplesfolder. - Start writing your game. Your logic should be stored in
lib.rs(and other files that are pulled in from it). Then, add all of the plugins and build yourAppinmain.rs. - If you only care about your game working on
nightly, removestablefrom thetoolchainfield in.github/workflows/ci.yml.
If you are making a standalone library:
- Delete
main.rsand the[[bin]]section of the top-levelCargo.toml. - Disable
bevyfeatures: changedefault-featurestofalseand disable thedynamicfeature. This avoids unnecessarily pulling in extra features for your users.
Finally:
- Rename the lib and bin in
Cargo.toml(and all imports to ensure your code compiles). - Double check that the LICENSE matches your intent.
- Update this README to match your project, modifying
About,Getting Startedand other sections as needed. - Consider cleaning up the issue and PR templates found in the
.githubfolder to better match your needs.
Use cargo run.
This repo is set up to always build with full optimizations, so there's no need for a --release flag in most cases.
Dynamic linking is enabled to ensure build times stay snappy.
To run an example, use cargo run --example_name, where example_name is the file name of the example without the .rs extension.
A build will be produced for Windows, MacOS and Linux each time a tag is pushed to GitHub.
These can be found under the Releases tab of your project.
See CONTRIBUTING.md!
- Use doc tests aggressively to show how APIs should be used.
You can use
#to hide a setup line from the doc tests. - Unit test belong near the code they are testing. Use
#[cfg(test)]on the test module to ignore it during builds, and#[test]on the test functions to ensure they are run. - Integration tests should be stored in the top level
testsfolder, importing functions fromlib.rs.
Use cargo test to run all tests.
The CI will:
- Ensure the code is formatted with
cargo fmt. - Ensure that the code compiles.
- Ensure that (almost) all
clippylints pass. - Ensure all tests pass on Windows, MacOS and Ubuntu.
Check this locally with:
cargo run -p cicargo test --workspace
To manually rerun CI:
- Navigate to the
Actionstab. - Use the dropdown menu in the CI run of interest and select "View workflow file".
- In the top-right corner, select "Rerun workflow".
Reference documentation is handled with standard Rust doc strings.
Use cargo doc --open to build and then open the docs.
Design docs (or other book-format documentation) is handled with mdBook.
Install it with cargo install mdbook, then use mdbook serve --open to launch the docs.
To run the benchmarks, use cargo bench.
For more documentation on making your own benchmarks, check out criterion's docs.