Template for a Bevy game

Overview

A Bevy game template

Template for a Game using the awesome Bevy engine featuring (almost) out of the box builds for Windows, Linux and MacOS.

What does this template give you?

  • basic setup with an executable crate on the root level and your game as a Bevy plugin in a library
  • small example game (warning: biased; e.g. split into a lot of plugins and using bevy_kira_audio for sound)
  • workflow for GitHub actions creating releases for Windows, Linux and MacOS ready for distribution
    • push a tag in the form of v[0-9]+.[0-9]+.[0-9]+* (e.g. v1.1.42) to trigger the flow

How to use this template?

  1. Create a repository based on this template
  2. Look for ToDo to use your own game name everywhere
  3. Update the icons as described below
  4. Start coding 🎉

Updating the icons

  1. Replace build/windows/icon.ico (icon used for windows executable)
  2. Replace build/macos/icon_1024x1024.png with a 1024 times 1024 pixel png icon and run create_icns.sh (make sure to run the script inside the macos directory) - Warning: sadly this seems to require a mac...

Getting started with Bevy

You should checkout the bevy website for links to resources. I can also recommend the official Discord server as a place to keep up to date with the development and get feedback + help from other Bevy users.

Todo

  • Add wasm build

License

This project is licensed under CC0 1.0 Universal except the content of assets and the Bevy icons in the build directory. Go crazy and feel free to show me whatever you build with this (@nikl_me).

Comments
  • Running `cargo make serve` on Windows fails

    Running `cargo make serve` on Windows fails

    I've forked your template and trying to run on web 'as-is'. It finishes compilation and then unfortunately fails with this:

       ...
       Replacing C:\Users\username\.cargo\bin\wasm2es6js.exe
        Replaced package `wasm-bindgen-cli v0.2.69` with `wasm-bindgen-cli v0.2.69` (executables `wasm-bindgen-test-runner.exe`, `wasm-bindgen.exe`, 
    `wasm2es6js.exe`)
    [cargo-make] INFO - Execute Command: "wasm-bindgen" "--out-dir" "target/wasm32-unknown-unknown/release/" "--out-name" "wasm" "--target" "web" "--no-typescript" "target/wasm32-unknown-unknown/release/bevy_game.wasm"
    [cargo-make] INFO - Execute Command: "mkdir" "-p" "build/web/target"
    [cargo-make] ERROR - Error while executing command, error: Os {
        code: 2,
        kind: NotFound,
        message: "The system cannot find the file specified.",
    }
    

    I think it's something trivial, but I can't figure it out.

    opened by rgripper 17
  • Rust Analyser + Symlink to Apps on MacOs = 🤯

    Rust Analyser + Symlink to Apps on MacOs = 🤯

    Hello, thank you for awesome template.

    I encountered issues using it with rust-analyser, it seems that it tried to analyse everything (ok) and even went through symlinks (not ok). Project could not be compiled and everything I got was:

    Blocking waiting for file lock on build directory
    

    I was able to solve the issue by deleting the symlink to Applications. Is this symlink necessary?

    opened by ierehon1905 8
  • Wasm builds fail

    Wasm builds fail

    Thanks for making this template, but when I try to follow the steps to build for web on a fresh clone of this repo, it fails with the following output:

    Finished dev [optimized + debuginfo] target(s) in 2m 01s Running wasm-server-runner target/wasm32-unknown-unknown/debug/bevy_game.wasm thread 'main' panicked at 'index out of bounds: the len is 0 but the index is 0', /home/pixelartist/.cargo/registry/src/github.com-1ecc6299db9ec823/wasm-bindgen-cli-support-0.2.79/src/descriptor.rs:208:15

    I get the same error when I try to use Github Actions to build this template from tags. It seems like an issue with the wasm-bindgen step?

    However, I am able to build the standard Bevy examples to web just fine.

    Is anyone else running into this issue? I'm running the latest version of Pop OS (Linux) and am able to build the template for Linux just fine, just not for web.

    opened by sfarmer1 6
  • Add instructions for icon creation on macOS

    Add instructions for icon creation on macOS

    • Switch the order of the two instructions (because the instructions I added depended on the mac icons being generated first)
    • Add sub-instructions for how to generate the windows .ico file on macOS

    This took me over an hour to figure out, so I thought I'd write some documentation so I don't have to figure it out again (because, let's be honest, I'm not going to remember it 😛).

    opened by CleanCut 5
  • Centre Bevy window in HTML webpage

    Centre Bevy window in HTML webpage

    Thanks for the fantastic template! In particular, the GitHub actions are great - I like how you can manually trigger the deployments with a workflow_dispatch trigger :)

    This is a minor suggestion that should help developers customise the frontend webpage that the WASM window gets embedded within. Currently the Bevy app loads into a <canvas> (with no settable id) which is injected into the <body> - which means you can't place it before loading, and it has no identifier to help you find it afterwards.

    This PR adds a script setup_display.js which waits for the Bevy <canvas> to load, and then moves it into a div with id="wasm-window", which means you can design the web page by styling the wasm-window element.

    By default the template webpage's <div id="wasm-window"> is placed within a <div class="container"> which will centre the game window within the middle of the page:

    Screenshot 2022-07-22 at 17 14 16

    It should then be straightforward to further customise the index.html page.

    opened by FreddyWordingham 5
  • Universal Binaries for MacOS Builds

    Universal Binaries for MacOS Builds

    References:

    • https://stackoverflow.com/a/66875783
    • https://developer.apple.com/documentation/apple-silicon/building-a-universal-macos-binary

    To test the MacOS build, check out this release from my fork.

    opened by divark 3
  • What's the purpose of splitting the game in a separate lib?

    What's the purpose of splitting the game in a separate lib?

    I'm not sure if it's appropriate to ask here, but I was curious what exactly is the benefit of splitting the game in it's own lib. Is it to help with compile time?

    opened by IceSentry 3
  • Plugins memo for newcomers

    Plugins memo for newcomers

    Hey, Rust newbie here, and I just discovered this great game template, and I think it definitely helped me a lot in understanding how Bevy works!

    However, since there's a lot of code in here in the src directory, I made myself a small "memo" to list all the plugins and what they're used for.

    It's there: https://github.com/Pierstoval/TestBevy/blob/main/memo.md

    Do you think this could somehow be added to this project's documentation somehow, with rewrites and adaptations of course?

    I think some plugins could refer to very specific documentation pages on Bevy docs, like transformations, audio, or assets.

    WDYT?

    opened by Pierstoval 3
  • Separate GameControl from actions and simplify the logic

    Separate GameControl from actions and simplify the logic

    Love this template a lot, but I feel that actions.rs has a lot going on and separation of concerns is in place.

    So I created a module for the game control. In my projects, the actions and game_control start to grow soon, so having them in different files, to begin with, is helpful.

    The current actions logic is also hard to read and manage. I think if the is_pressed would just return 1.0 or 0.0, the normalized movement can be calculated from Left - Right or Up-Down.

    What do you think?

    opened by jrasanen 2
  • deploy-github-page fails if you use local paths in cargo.toml

    deploy-github-page fails if you use local paths in cargo.toml

    As the title says, the deploy-github-page action fails if your cargo.toml has a local path dependency. Maybe this should have been obvious to me but it caught me off guard a bit as when you publish to crates.io it strips the local dependencies out and falls back to the published crate.

    If this isn't really a bug it might at least be worth noting in the readme that you should remove local paths before publishing as the cause wasn't immediately obvious.

    Failed output from the "Build release" step
    Run trunk build --release --public-url "${GITHUB_REPOSITORY#*/}"
    2022-08-31T08:00:[4](https://github.com/sarkahn/bevy_ascii_tetris/runs/8108815613?check_suite_focus=true#step:8:5)4.290680Z  INFO 📦 starting build
    2022-08-31T08:00:44.2912[5](https://github.com/sarkahn/bevy_ascii_tetris/runs/8108815613?check_suite_focus=true#step:8:6)1Z  INFO spawning asset pipelines
    2022-08-31T08:00:45.[6](https://github.com/sarkahn/bevy_ascii_tetris/runs/8108815613?check_suite_focus=true#step:8:7)56057Z ERROR ❌ error
    error from HTML pipeline
    
    Caused by:
        0: error getting cargo metadata
    Error: error from HTML pipeline
        1: `cargo metadata` exited with an error: error: failed to get `bevy` as a dependency of package `bevy_ascii_tetris v0.1.0 (/home/runner/work/bevy_ascii_tetris/bevy_ascii_tetris)`
           
           Caused by:
    
    Caused by:
        0: error getting cargo metadata
        1: `cargo metadata` exited with an error: error: failed to get `bevy` as a dependency of package `bevy_ascii_tetris v0.1.0 (/home/runner/work/bevy_ascii_tetris/bevy_ascii_tetris)`
           
           Caused by:
             failed to load source for dependency `bevy`
           
           Caused by:
             Unable to update /home/runner/work/bevy_ascii_tetris/bevy
           
           Caused by:
             failed to read `/home/runner/work/bevy_ascii_tetris/bevy/Cargo.toml`
           
           Caused by:
             No such file or directory (os error 2)
             failed to load source for dependency `bevy`
           
           Caused by:
             Unable to update /home/runner/work/bevy_ascii_tetris/bevy
           
           Caused by:
             failed to read `/home/runner/work/bevy_ascii_tetris/bevy/Cargo.toml`
           
           Caused by:
             No such file or directory (os error 2)
    
    opened by sarkahn 2
  • GitHub pages support

    GitHub pages support

    Are you interested in supporting GitHub pages for WASM builds? I wanted to make my game's releases very easy to play. For the moment I just added

          - name: Deploy to GitHub Pages
            uses: JamesIves/[email protected]
            with:
              branch: gh-pages
              folder: wasm
              clean-exclude: index.html
    

    as an additional step of the release-wasm job.

    In the future extending this feature to support multiple (all available) release and not just the most recent on could be very interesting.

    opened by XBagon 2
  • RFC: Cargo generate example.

    RFC: Cargo generate example.

    Convert template into a cargo generate template.

    You can then use cargo generate to stamp out a project, similar to cookiecutter. This approach removes the need to search for "TODO" as all the values are derived from the prohject name. In addition it removes the risk of typos/inconsistencies between values.

    Let me know your thoughts.

    opened by Stedders 0
  • Refactor plugins; Highlight debug-assertions in Cargo.toml

    Refactor plugins; Highlight debug-assertions in Cargo.toml

    Hi there,

    I found it more useful to isolate all of the starter, default plugins, logic, etc into its own "default" folder, so that I can better decouple the bevy_game starter template from the additional things I want to add to the project.

    Also, incidentally it shows users of this template how they can organize their own code as well.

    Lastly, I added a debug-assertions line in the Cargo.toml so that it's more obvious to users of this template how they can disable the default "frame diagnostic" logging that would otherwise normally flood stdout whenever they run the application.

    edit - Also, by using public and private, it sets a good example for the users of this template to follow, so that their code is more organized and not just 5_000 lines in a single file.

    opened by wanderrful 1
Releases(v0.1.0-test.9)
Owner
Niklas Eicker
Niklas Eicker
Bevy Simple Portals is a Bevy game engine plugin aimed to create portals.

Portals for Bevy Bevy Simple Portals is a Bevy game engine plugin aimed to create portals. Those portals are (for now) purely visual and can be used t

Sélène Amanita 11 May 28, 2023
2d Endless Runner Game made with Bevy Game Engine

Cute-runner A 2d Endless Runner Game made with Bevy Game Engine. Table of contents Project Infos Usage Screenshots Disclaimer Project Infos Date: Sept

JoaoMarinho 2 Jul 15, 2022
A game of snake written in Rust using the Bevy game engine, targeting WebGL2

Snake using the Bevy Game Engine Prerequisites cargo install cargo-make Build and serve WASM version Set your local ip address in Makefile.toml (loca

Michael Dorst 0 Dec 26, 2021
A game made in one week for the Bevy engine's first game jam

¿Quien es el MechaBurro? An entry for the first Bevy game jam following the theme of "Unfair Advantage." It was made in one week using the wonderful B

mike 20 Dec 23, 2022
A Client/Server game networking plugin using QUIC, for the Bevy game engine.

Bevy Quinnet A Client/Server game networking plugin using QUIC, for the Bevy game engine. Bevy Quinnet QUIC as a game networking protocol Features Roa

Gilles Henaux 65 Feb 20, 2023
Solana Game Server is a decentralized game server running on Solana, designed for game developers

Solana Game Server* is the first decentralized Game Server (aka web3 game server) designed for game devs. (Think web3 SDK for game developers as a ser

Tardigrade Life Sciences, Inc 16 Dec 1, 2022
An opinionated, monolithic template for Bevy with cross-platform CI/CD, native + WASM launchers, and managed cross-platform deployment.

??️ Bevy Shell - Template An opinionated, monolithic template for Bevy with cross-platform CI/CD, native + WASM launchers, and managed cross-platform

Kurbos 218 Dec 30, 2022
Neutral cross-platform Rust game template

Rust Game Template Neutral cross-platform Rust game template. Build tool This project uses cargo-make task runner. It's required to build the project.

null 0 Feb 5, 2022
Template game client for the Software Challenge 2023 ("Hey, Danke für den Fisch!")

Software Challenge 2023 Rust Client A template client for the Software Challenge 2023 (Hey, Danke für den Fisch!) written in Rust. The client implemen

FW 3 Nov 4, 2022
bevy-hikari is an implementation of voxel cone tracing global illumination with anisotropic mip-mapping in Bevy

Bevy Voxel Cone Tracing bevy-hikari is an implementation of voxel cone tracing global illumination with anisotropic mip-mapping in Bevy. Bevy Version

研究社交 208 Dec 27, 2022
A simple extension for `bevy-editor-pls` to support tilemap editing right inside the bevy app.

What is this This is a simple tilemap editor plugin, that hooks right into bevy_editor_pls to work with bevy_ecs_tilemap. It works completely within i

null 3 May 8, 2023
Minecraft using Bevy and Bevy-Meshem

minecraft_bevy Minecraft_bevy was built to showcase bevy_meshem. After a week of developing it has: Chunk loading / unloading each chunk's mesh is bei

Adam 7 Oct 4, 2023
Basic first-person fly camera for the Bevy game engine

bevy_flycam A basic first-person fly camera for Bevy 0.4 Controls WASD to move horizontally SPACE to ascend LSHIFT to descend ESC to grab/release curs

Spencer Burris 85 Dec 23, 2022
Inspector plugin for the bevy game engine

bevy-inspector-egui This crate provides the ability to annotate structs with a #[derive(Inspectable)], which opens a debug interface using egui where

Jakob Hellermann 517 Dec 31, 2022
Crossterm plugin for the bevy game engine

What is bevy_crossterm? bevy_crossterm is a Bevy plugin that uses crossterm as a renderer. It provides custom components and events which allow users

null 79 Nov 2, 2022
Game physics in one weekend with bevy

Game Physics in a Weekend (in Rust) This project is an implementation of the Game Physics in a Weekend book using the Rust programming language and th

Cameron Hart 28 Dec 23, 2022
A Bevy plugin to use Kira for game audio

Bevy Kira audio This bevy plugin is intended to try integrating Kira into Bevy. The end goal would be to replace or update bevy_audio, if Kira turns o

Niklas Eicker 172 Jan 5, 2023
Concise Reference Book for the Bevy Game Engine

Unofficial Bevy Cheat Book Click here to read the book! Concise reference to programming in the Bevy game engine. Covers useful syntax, features, prog

null 947 Jan 8, 2023
Proof-of-concept of getting OpenXR rendering support for Bevy game engine using gfx-rs abstractions

Introduction Proof-of-concept of getting OpenXR rendering support for Bevy game engine using gfx-rs abstractions. (hand interaction with boxes missing

Mika 52 Nov 14, 2022