This template is a great way to get started on a new 2D Bevy game! Start with a basic project and CI / CD that can deploy to itch.io. You can try this template in your browser!
We assume that you're familiar with Bevy and have already seen the official Quick Start Guide.
If you're new to Bevy, the patterns used in this template may look a bit weird at first glance. See our Design Document for more information on how we structured the code and why.
Install bevy_cli
and run the following command:
bevy new my_game --template 2d
Then create a GitHub repository and push your local repository to it.
The best way to get started is to play around with the code you find in src/demo/
.
This template comes with a basic project structure that you may find useful:
Path | Description |
---|---|
src/main.rs |
App setup |
src/asset_tracking.rs |
A high-level way to load collections of asset handles as resources |
src/audio.rs |
Marker components for sound effects and music |
src/dev_tools.rs |
Dev tools for dev builds (press ` aka backtick to toggle) |
src/demo/ |
Example game mechanics & content (replace with your own code) |
src/screens/ |
Splash screen, title screen, gameplay screen, etc. |
src/theme/ |
Reusable UI widgets & theming |
Feel free to move things around however you want, though.
Tip
Be sure to check out the 3rd-party tools we recommend!
We recommend using the Bevy CLI to run your game.
Running your game locally is very simple:
- Use
bevy run
to run a native dev build. - Use
bevy run web
to run a web dev build.
This template also comes with VS Code tasks and JetBrains run configurations to help run your game from your IDE.
Running release builds
- Use
bevy run --release
to run a native release build. - Use
bevy run --release web
to run a web release build.
Installing Linux dependencies
If you're using Linux, make sure you've installed Bevy's Linux dependencies.
Note that this template enables Wayland support, which requires additional dependencies as detailed in the link above.
Wayland is activated by using the bevy/wayland
feature in the Cargo.toml
.
(Optional) Improving compile times
.cargo/config_fast_builds.toml
contains documentation on how to set up your environment to improve compile times.
After you've fiddled with it, rename it to .cargo/config.toml
to enable it.
(Optional) Hot-patching with subsecond
Hot-patching is an experimental feature that allows you to edit your game's code while it's running and see the changes without having to recompile or restart.
To set this up, follow the instructions in bevy_simple_subsecond_system
.
Make sure to read the Known Limitations
section and update your Cargo.toml
:
[dependencies]
+ bevy_simple_subsecond_system = { version = "0.1", optional = true }
[features]
dev_native = [
+ "dep:bevy_simple_subsecond_system",
]
Annotate your systems to enable hot-patching. The functions they call can be hot-patched too; no additional annotations required!
#[cfg_attr(feature = "dev_native", hot)]
fn my_system() {}
Run your game with hot-patching enabled:
dx serve --hot-patch
Now edit an annotated system's code while the game is running, and save the file.
You should see Status: Hot-patching...
in the CLI if you've got it working.
This template uses GitHub workflows to run tests and build releases. See Workflows for more information.
There are some known issues in Bevy that can require arcane workarounds. To keep this template simple, we've opted to leave these workarounds out. You can read about them in the Known Issues document.
The source code in this repository is licensed under any of the following at your option:
The CC0 license explicitly does not waive patent rights, but we confirm that we hold no patent rights to anything presented in this repository.
The assets in this repository are all 3rd-party. See the credits screen for more information.