├── template_lib ├── src │ ├── audio │ │ └── mod.rs │ ├── menus │ │ ├── mod.rs │ │ ├── main_menu.rs │ │ └── pause_menu.rs │ ├── asset_management.rs │ ├── player │ │ ├── cursor.rs │ │ ├── mod.rs │ │ └── camera.rs │ ├── simulation │ │ └── mod.rs │ ├── lib.rs │ └── graphics │ │ ├── mod.rs │ │ └── lighting.rs ├── tests │ └── test_setup.rs └── Cargo.toml ├── template_macros ├── src │ └── lib.rs └── Cargo.toml ├── clippy.toml ├── rust-toolchain.toml ├── .gitignore ├── design └── src │ ├── SUMMARY.md │ ├── genre-analysis.md │ ├── overview.md │ └── rfc │ └── template.md ├── book.toml ├── assets └── asset-licenses.csv ├── RELEASES.md ├── tools └── ci │ ├── Cargo.toml │ └── src │ └── main.rs ├── template_game ├── Cargo.toml └── src │ └── main.rs ├── Cargo.toml ├── .gitattributes ├── LICENSE-MIT.md ├── .cargo └── config.toml ├── CONTRIBUTING.md ├── README.md └── LICENSE-APACHE.md /template_lib/src/audio/mod.rs: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /template_lib/src/menus/mod.rs: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /template_macros/src/lib.rs: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /template_lib/src/asset_management.rs: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /template_lib/src/menus/main_menu.rs: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /template_lib/src/menus/pause_menu.rs: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /clippy.toml: -------------------------------------------------------------------------------- 1 | type-complexity-threshold = 5000 -------------------------------------------------------------------------------- /rust-toolchain.toml: -------------------------------------------------------------------------------- 1 | [toolchain] 2 | channel = "nightly" 3 | -------------------------------------------------------------------------------- /template_lib/src/player/cursor.rs: -------------------------------------------------------------------------------- 1 | /// Code to control the cursor actions -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | book 2 | 3 | 4 | # Added by cargo 5 | 6 | /target 7 | 8 | Cargo.lock 9 | -------------------------------------------------------------------------------- /template_lib/tests/test_setup.rs: -------------------------------------------------------------------------------- 1 | #![cfg(test)] 2 | 3 | #[test] 4 | fn minimal_app_can_update() {} 5 | -------------------------------------------------------------------------------- /design/src/SUMMARY.md: -------------------------------------------------------------------------------- 1 | # Summary 2 | 3 | - [Overview](./overview.md) 4 | - [Genre analysis](./genre-analysis.md) 5 | -------------------------------------------------------------------------------- /book.toml: -------------------------------------------------------------------------------- 1 | [book] 2 | authors = ["Alice Cecile"] 3 | language = "en" 4 | multilingual = false 5 | src = "design/src" 6 | title = "TEMPLATE" 7 | -------------------------------------------------------------------------------- /assets/asset-licenses.csv: -------------------------------------------------------------------------------- 1 | Asset Name,License,Author,Link 2 | swallow.svg,CC-BY-3.0,Delapouite,https://game-icons.net/1x1/delapouite/swallow.html 3 | -------------------------------------------------------------------------------- /template_lib/src/simulation/mod.rs: -------------------------------------------------------------------------------- 1 | /// Code to run game logic. 2 | /// 3 | /// This should not contain logic to render and should be able to work without a render pipeline. -------------------------------------------------------------------------------- /RELEASES.md: -------------------------------------------------------------------------------- 1 | # Release Notes 2 | 3 | ## Version 0.1 4 | 5 | - Update template to `bevy` 0.10 6 | - Improve game architecture 7 | - added game basics for easy use of template 8 | 9 | ## Version 0.0 10 | 11 | - Template release, plz ignore 12 | -------------------------------------------------------------------------------- /design/src/genre-analysis.md: -------------------------------------------------------------------------------- 1 | # Genre analysis 2 | 3 | ## Exemplars 4 | 5 | ## Adjacent games 6 | 7 | ## Core Fantasy 8 | 9 | ## Nouns 10 | 11 | ## Verbs 12 | 13 | ## Moment-to-moment loop 14 | 15 | ## Core loop 16 | 17 | ## Progression loop 18 | 19 | ## Tensions 20 | 21 | ## Strengths 22 | 23 | ## Weaknesses 24 | -------------------------------------------------------------------------------- /template_lib/src/lib.rs: -------------------------------------------------------------------------------- 1 | //! Connects all of the TEMPLATE game logic. 2 | #![deny(missing_docs)] 3 | #![deny(clippy::missing_docs_in_private_items)] 4 | #![forbid(unsafe_code)] 5 | #![warn(clippy::doc_markdown)] 6 | // Often exceeded by queries 7 | #![allow(clippy::type_complexity)] 8 | 9 | pub mod graphics; 10 | pub mod player; 11 | -------------------------------------------------------------------------------- /tools/ci/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ci" 3 | version = "0.1.0" 4 | edition = "2021" 5 | description = "CI script for TEMPLATE" 6 | publish = false 7 | license = "MIT OR Apache 2.0" 8 | 9 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 10 | [dependencies] 11 | xshell = "0.2" 12 | bitflags = "1.3" -------------------------------------------------------------------------------- /template_game/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "template_game" 3 | version = "0.1.0" 4 | license = "MIT OR Apache-2.0" 5 | authors = ["Leafwing Studios"] 6 | edition = "2021" 7 | 8 | [dependencies] 9 | bevy = { git = "https://github.com/bevyengine/bevy", rev="f7fbfaf", default-features = false} 10 | template_lib ={ path = "../template_lib", version = "0.1"} -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | resolver = "2" 3 | 4 | members = [ 5 | "template_game", 6 | "template_lib", 7 | "template_macros", 8 | "tools/ci" 9 | ] 10 | 11 | default-members = ["template_game","template_lib"] 12 | 13 | # Enable max dependenacy optimizations without impacting release compiles 14 | [profile.dev.package."*"] 15 | opt-level = 3 -------------------------------------------------------------------------------- /template_lib/src/player/mod.rs: -------------------------------------------------------------------------------- 1 | //! Code that connects player character logic 2 | use bevy::prelude::{App, Plugin}; 3 | 4 | pub mod camera; 5 | 6 | /// Create a plugin to use with the main game logic 7 | pub struct PlayerPlugin; 8 | 9 | impl Plugin for PlayerPlugin { 10 | fn build(&self, app: &mut App) { 11 | app.add_plugin(camera::CameraPlugin); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /template_lib/src/player/camera.rs: -------------------------------------------------------------------------------- 1 | //! Code needed to run the game camera 2 | 3 | use bevy::prelude::*; 4 | 5 | /// Camera logic 6 | pub struct CameraPlugin; 7 | 8 | impl Plugin for CameraPlugin { 9 | fn build(&self, app: &mut App) { 10 | app.add_startup_system(camera_setup); 11 | } 12 | } 13 | 14 | /// Spawn the player camera 15 | fn camera_setup(mut commands: Commands) { 16 | commands.spawn(Camera3dBundle::default()); 17 | } 18 | -------------------------------------------------------------------------------- /template_macros/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "template_macros" 3 | description = "Macros for a bevy game" 4 | version = "0.1.0" 5 | license = "MIT OR Apache-2.0" 6 | edition = "2021" 7 | authors = ["Leafwing Studios"] 8 | homepage = "https://leafwing-studios.com/" 9 | repository = "https://github.com/Leafwing-Studios/Emergence" 10 | 11 | [lib] 12 | proc-macro = true 13 | 14 | [dependencies] 15 | syn = "1.0" 16 | quote = "1.0" 17 | proc-macro2 = "1.0" 18 | proc-macro-crate = "1.1" -------------------------------------------------------------------------------- /template_lib/src/graphics/mod.rs: -------------------------------------------------------------------------------- 1 | //! Logic for starting the graphics pipeline 2 | use bevy::prelude::{App, Plugin}; 3 | 4 | use self::lighting::LightingPlugin; 5 | 6 | mod lighting; 7 | 8 | /// Adds game logic for rendering the game world. 9 | /// 10 | /// This should only contain logic to render and the game simulation should run without this. 11 | pub struct GraphicsPlugin; 12 | 13 | impl Plugin for GraphicsPlugin { 14 | fn build(&self, app: &mut App) { 15 | app.add_plugin(LightingPlugin); 16 | } 17 | } 18 | 19 | // fn render_terrain 20 | -------------------------------------------------------------------------------- /template_lib/src/graphics/lighting.rs: -------------------------------------------------------------------------------- 1 | //! Lights and lighting. 2 | // Modified from Leafwing *Emergence* 3 | 4 | use bevy::prelude::*; 5 | 6 | /// Handles all lighting logic 7 | pub(super) struct LightingPlugin; 8 | 9 | impl Plugin for LightingPlugin { 10 | fn build(&self, app: &mut App) { 11 | app.insert_resource(AmbientLight { 12 | brightness: 1., 13 | color: Color::WHITE, 14 | }) 15 | .add_startup_system(spawn_sun); 16 | } 17 | } 18 | 19 | /// Spawns a directional light source to illuminate the scene 20 | fn spawn_sun(mut commands: Commands) { 21 | commands.spawn(DirectionalLightBundle { 22 | transform: Transform::from_xyz(30., 100., 30.).looking_at(Vec3::ZERO, Vec3::Y), 23 | ..default() 24 | }); 25 | } 26 | -------------------------------------------------------------------------------- /template_game/src/main.rs: -------------------------------------------------------------------------------- 1 | //! Everything needed to run the main game logic 2 | 3 | use bevy::prelude::*; 4 | 5 | /// Set the game state to align systems with their respective runtimes 6 | #[derive(Debug, Clone, Copy, Default, Eq, PartialEq, Hash, States)] 7 | enum GameState { 8 | #[default] 9 | Menu, 10 | Playing, 11 | } 12 | 13 | fn main() { 14 | App::new() 15 | .add_plugins(DefaultPlugins.set(WindowPlugin { 16 | primary_window: Some(Window { 17 | title: String::from("Bevy 3D Template"), 18 | ..default() 19 | }), 20 | ..default() 21 | })) 22 | .add_plugin(template_lib::player::PlayerPlugin) 23 | .add_plugin(template_lib::graphics::GraphicsPlugin) 24 | .run(); 25 | } 26 | -------------------------------------------------------------------------------- /template_lib/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "template_lib" 3 | version = "0.1.0" 4 | authors = ["Leafwing Studios"] 5 | license = "MIT OR Apache 2.0" 6 | edition = "2021" 7 | 8 | [dependencies] 9 | bevy = { git = "https://github.com/bevyengine/bevy", rev="f7fbfaf", default-features = false, features = [ 10 | "bevy_asset", 11 | "bevy_core_pipeline", 12 | "bevy_gilrs", 13 | "bevy_pbr", 14 | "bevy_render", 15 | "bevy_scene", 16 | "bevy_winit", 17 | "png", 18 | # "trace_tracy", 19 | "x11", 20 | ] } 21 | # bevy_kira_audio ={ git = "https://github.com/NiklasEi/bevy_kira_audio?branch=bevy_main", features = ["mp3"]} 22 | rand = "0.8" 23 | # template_macros = {version = "0.1", path = "../template_macros"} 24 | petitset = "0.2" 25 | serde = "1.0.152" 26 | derive_more = "0.99.17" -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | *.png filter=lfs diff=lfs merge=lfs -text 2 | *.svg filter=lfs diff=lfs merge=lfs -text 3 | *.jpg filter=lfs diff=lfs merge=lfs -text 4 | *.gif filter=lfs diff=lfs merge=lfs -text 5 | *.mpeg filter=lfs diff=lfs merge=lfs -text 6 | *.zip filter=lfs diff=lfs merge=lfs -text 7 | *.7z filter=lfs diff=lfs merge=lfs -text 8 | *.avi filter=lfs diff=lfs merge=lfs -text 9 | *.bmp filter=lfs diff=lfs merge=lfs -text 10 | *.mp3 filter=lfs diff=lfs merge=lfs -text 11 | *.wav filter=lfs diff=lfs merge=lfs -text 12 | *.png filter=lfs diff=lfs merge=lfs -text 13 | *.tar filter=lfs diff=lfs merge=lfs -text 14 | *.gltf filter=lfs diff=lfs merge=lfs -text 15 | *.ttf filter=lfs diff=lfs merge=lfs -text 16 | *.otf filter=lfs diff=lfs merge=lfs -text 17 | *.ods filter=lfs diff=lfs merge=lfs -text 18 | *.ogg filter=lfs diff=lfs merge=lfs -text 19 | *.psd filter=lfs diff=lfs merge=lfs -text 20 | *.max filter=lfs diff=lfs merge=lfs -text 21 | *.blend filter=lfs diff=lfs merge=lfs -text 22 | *.fbx filter=lfs diff=lfs merge=lfs -text 23 | *.dae filter=lfs diff=lfs merge=lfs -text 24 | *.obj filter=lfs diff=lfs merge=lfs -text 25 | -------------------------------------------------------------------------------- /LICENSE-MIT.md: -------------------------------------------------------------------------------- 1 | # MIT License 2 | 3 | Copyright (c) 2021 Leafwing Studios 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /.cargo/config.toml: -------------------------------------------------------------------------------- 1 | # Enables the beta rust 1.68 crates index protocol testing. 2 | # This should offer crates indexing/compile/build time improvements 3 | # See https://blog.rust-lang.org/inside-rust/2023/01/30/cargo-sparse-protocol.html for info 4 | [registries.crates.io] 5 | protocol = "sparse" 6 | 7 | # NOTE: For maximum performance, build using a nightly compiler and uncomment `"-Zshare-generics=y",` 8 | # If you are using rust stable, remove the "-Zshare-generics=y" below. 9 | 10 | [target.x86_64-unknown-linux-gnu] 11 | linker = "clang" 12 | rustflags = [ 13 | "-Clink-arg=-fuse-ld=lld", 14 | "-Zshare-generics=y", 15 | ] 16 | 17 | # NOTE: you must install [Mach-O LLD Port](https://lld.llvm.org/MachO/index.html) on mac. you can easily do this by installing llvm which includes lld with the "brew" package manager: 18 | # `brew install llvm` 19 | [target.x86_64-apple-darwin] 20 | rustflags = [ 21 | "-C", 22 | "link-arg=-fuse-ld=/usr/local/opt/llvm/bin/ld64.lld", 23 | "-Zshare-generics=y", 24 | ] 25 | 26 | [target.aarch64-apple-darwin] 27 | rustflags = [ 28 | "-C", 29 | "link-arg=-fuse-ld=/opt/homebrew/opt/llvm/bin/ld64.lld", 30 | "-Zshare-generics=y", 31 | ] 32 | 33 | [target.x86_64-pc-windows-msvc] 34 | linker = "rust-lld.exe" 35 | rustflags = ["-Zshare-generics=n"] 36 | 37 | # Optional: Uncommenting the following improves compile times, but reduces the amount of debug info to 'line number tables only' 38 | # In most cases the gains are negligible, but if you are on macos and have slow compile times you should see significant gains. 39 | #[profile.dev] 40 | #debug = 1 41 | -------------------------------------------------------------------------------- /design/src/overview.md: -------------------------------------------------------------------------------- 1 | # Overview 2 | 3 | ## Big Picture 4 | 5 | ### Elevator Pitch 6 | 7 | In one short sentence, what is this game about? 8 | 9 | ### Target Audience 10 | 11 | Who are we making this game for? 12 | 13 | ### Themes 14 | 15 | What is the fantasy we’re trying to create? What message are we trying to send? 16 | 17 | ## Mechanics 18 | 19 | ### Moment-to-moment Loop 20 | 21 | What does the player do, in the tightest gameplay cycle? 22 | 23 | ### Game Loop 24 | 25 | What does the player do in a single, self-contained session of play? 26 | 27 | ### Progression Loop 28 | 29 | How does the game loop evolve between sessions? 30 | 31 | ### Objects 32 | 33 | The nouns that define the world. 34 | 35 | ### Actions 36 | 37 | The verbs that define what players can do. 38 | 39 | ### Resources 40 | 41 | The currency-like pools that resources can build up, spend and convert. 42 | 43 | ### Design Invariants 44 | 45 | What patterns and restrictions are we imposing on ourselves to make reasoning about the design easier? 46 | 47 | ### Design Constraints 48 | 49 | What problems will be deal-breakers for players? What restrictions are we imposing on ourselves? 50 | 51 | ### Design Tolerances 52 | 53 | What unusual flaws or unconventional choices will our players accept? 54 | 55 | ### Systems and Hooks 56 | 57 | How can we generate interesting complexity? 58 | 59 | ## Business 60 | 61 | ### Monetization Strategy 62 | 63 | How are we going to make money from our players? 64 | 65 | ### Marketing Strategy 66 | 67 | What channels are we going to use to reach our target audience? 68 | 69 | ### Marketing Hooks 70 | 71 | What game design elements can we focus on to push the marketability of this game? 72 | 73 | ## Technical 74 | 75 | ### Technical Strategy 76 | 77 | What platform(s) are we releasing on? Which engine? How large and experienced is our team? 78 | 79 | ### Technical Constraints 80 | 81 | What unexpected constraints are we likely to encounter? 82 | 83 | ### Technical Tolerances 84 | 85 | What parts will be easier than you might expect? Where can we cut corners? 86 | 87 | ## Art 88 | 89 | ### Art Strategy 90 | 91 | What basic style and techniques are we going to use? How big is our budget? 92 | 93 | ### Art Constraints 94 | 95 | What unexpected constraints are we likely to encounter? 96 | 97 | ### Art Tolerances 98 | 99 | What parts will be easier than you might expect? Where can we cut corners? 100 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | 2 | # Contributing 3 | 4 | This repository is open to community contributions! 5 | *Leafwing Studios* attempts to adhere to the [Rust API Guidelines](https://rust-lang.github.io/api-guidelines/about.html). 6 | If you haven't seen it before, it's an excellent resource! 7 | 8 | There are a few options if you'd like to help: 9 | 10 | 1. File issues for bugs you find or new features you'd like. 11 | 2. Read over and discuss issues, then make a PR that fixes them. Use "Fixes #X" in your PR description to automatically close the issue when the PR is merged. 12 | 3. Review existing PRs, and leave thoughtful feedback. If you think a PR is ready to merge, hit "Approve" in your review! 13 | 14 | Any contributions made are provided under the license(s) listed in this repo at the time of their contribution, and do not require separate attribution. 15 | 16 | ## Testing 17 | 18 | 1. Use doc tests aggressively to show how APIs should be used. 19 | You can use `#` to hide a setup line from the doc tests. 20 | 2. 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. 21 | 3. Integration tests should be stored in the top level `tests` folder, importing functions from `lib.rs`. 22 | 23 | Use `cargo test` to run all tests. 24 | 25 | ## CI 26 | 27 | The CI will: 28 | 29 | 1. Ensure the code is formatted with `cargo fmt`. 30 | 2. Ensure that the code compiles. 31 | 3. Ensure that (almost) all `clippy` lints pass. 32 | 4. Ensure all tests pass on Windows, MacOS and Ubuntu. 33 | 34 | Check this locally with: 35 | 36 | 1. `cargo run -p ci` 37 | 2. `cargo test --workspace` 38 | 39 | To manually rerun CI: 40 | 41 | 1. Navigate to the `Actions` tab. 42 | 2. Use the dropdown menu in the CI run of interest and select "View workflow file". 43 | 3. In the top-right corner, select "Rerun workflow". 44 | 45 | ## Documentation 46 | 47 | Reference documentation is handled with standard Rust doc strings. 48 | Use `cargo doc --open` to build and then open the docs. 49 | 50 | Design docs (or other book-format documentation) is handled with [mdBook](https://rust-lang.github.io/mdBook/index.html). 51 | Install it with `cargo install mdbook`, then use `mdbook serve --open` to launch the docs. 52 | 53 | ## Benchmarking 54 | 55 | To run the benchmarks, use `cargo bench`. 56 | 57 | For more documentation on making your own benchmarks, check out [criterion's docs](https://bheisler.github.io/criterion.rs/book/index.html). 58 | 59 | ## Publishing your crate 60 | 61 | This repository is designed to make publishing crates easy! Just follow [cargo's directions](https://doc.rust-lang.org/cargo/reference/publishing.html) and you'll be an official part of the Rust ecosystem in no time! 62 | -------------------------------------------------------------------------------- /tools/ci/src/main.rs: -------------------------------------------------------------------------------- 1 | //! Modified from [Bevy's CI runner](https://github.com/bevyengine/bevy/tree/main/tools/ci/src) 2 | 3 | use xshell::{cmd, Shell}; 4 | 5 | use bitflags::bitflags; 6 | 7 | bitflags! { 8 | struct Check: u32 { 9 | const FORMAT = 0b00000001; 10 | const CLIPPY = 0b00000010; 11 | const TEST = 0b00001000; 12 | const DOC_TEST = 0b00010000; 13 | const DOC_CHECK = 0b00100000; 14 | const COMPILE_CHECK = 0b100000000; 15 | } 16 | } 17 | 18 | // This can be configured as needed 19 | const CLIPPY_FLAGS: [&str; 3] = [ 20 | "-Aclippy::type_complexity", 21 | "-Wclippy::doc_markdown", 22 | "-Dwarnings", 23 | ]; 24 | 25 | fn main() { 26 | // When run locally, results may differ from actual CI runs triggered by 27 | // .github/workflows/ci.yml 28 | // - Official CI runs latest stable 29 | // - Local runs use whatever the default Rust is locally 30 | 31 | let arguments = [ 32 | ("lints", Check::FORMAT | Check::CLIPPY), 33 | ("test", Check::TEST), 34 | ("doc", Check::DOC_TEST | Check::DOC_CHECK), 35 | ("compile", Check::COMPILE_CHECK), 36 | ("format", Check::FORMAT), 37 | ("clippy", Check::CLIPPY), 38 | ("doc-check", Check::DOC_CHECK), 39 | ("doc-test", Check::DOC_TEST), 40 | ]; 41 | 42 | let what_to_run = if let Some(arg) = std::env::args().nth(1).as_deref() { 43 | if let Some((_, check)) = arguments.iter().find(|(str, _)| *str == arg) { 44 | *check 45 | } else { 46 | println!( 47 | "Invalid argument: {arg:?}.\nEnter one of: {}.", 48 | arguments[1..] 49 | .iter() 50 | .map(|(s, _)| s) 51 | .fold(arguments[0].0.to_owned(), |c, v| c + ", " + v) 52 | ); 53 | return; 54 | } 55 | } else { 56 | Check::all() 57 | }; 58 | 59 | let sh = Shell::new().unwrap(); 60 | 61 | if what_to_run.contains(Check::FORMAT) { 62 | // See if any code needs to be formatted 63 | cmd!(sh, "cargo fmt --all -- --check") 64 | .run() 65 | .expect("Please run 'cargo fmt --all' to format your code."); 66 | } 67 | 68 | if what_to_run.contains(Check::CLIPPY) { 69 | // See if clippy has any complaints. 70 | // --all-targets --all-features was removed because Emergence currently has no special 71 | // targets or features; please add them back as necessary 72 | cmd!(sh, "cargo clippy --workspace -- {CLIPPY_FLAGS...}") 73 | .run() 74 | .expect("Please fix clippy errors in output above."); 75 | } 76 | 77 | if what_to_run.contains(Check::TEST) { 78 | // Run tests (except doc tests and without building examples) 79 | cmd!(sh, "cargo test --workspace --lib --bins --tests --benches") 80 | .run() 81 | .expect("Please fix failing tests in output above."); 82 | } 83 | 84 | if what_to_run.contains(Check::DOC_TEST) { 85 | // Run doc tests 86 | cmd!(sh, "cargo test --workspace --doc") 87 | .run() 88 | .expect("Please fix failing doc-tests in output above."); 89 | } 90 | 91 | if what_to_run.contains(Check::DOC_CHECK) { 92 | // Check that building docs work and does not emit warnings 93 | std::env::set_var("RUSTDOCFLAGS", "-D warnings"); 94 | cmd!( 95 | sh, 96 | "cargo doc --workspace --all-features --no-deps --document-private-items" 97 | ) 98 | .run() 99 | .expect("Please fix doc warnings in output above."); 100 | } 101 | 102 | if what_to_run.contains(Check::COMPILE_CHECK) { 103 | cmd!(sh, "cargo check --workspace") 104 | .run() 105 | .expect("Please fix compiler errors in above output."); 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # About 2 | 3 | This is the Leafwing Studios' template repo, providing a quick, opinionated base for high-quality Bevy game projects (and libraries). 4 | We've shaved the yaks for you! 5 | 6 | The licenses here are provided for template purposes: this repository itself is provided under MIT-0. 7 | Feel free to use, hack and adopt this freely: no attribution needed. 8 | 9 | ## Instructions 10 | 11 | ### Getting started 12 | 13 | [Use this template](https://github.com/Leafwing-Studios/template-repo/generate) by pressing the big green "Use this template" button in the top right corner of [this repo](https://github.com/Leafwing-Studios/template-repo) to create a new repository. 14 | 15 | This repository has dynamic linking enabled for much faster incremental compile times. 16 | If you're on Windows, you'll need to use the `nightly` Rust compiler. 17 | Swap by using `rustup default nightly`. 18 | You may want to run `rustup update` afterwards to get your tools up to date. 19 | 20 | If you are making a game: 21 | 22 | 1. Enable the features you need from Bevy in `Cargo.toml`. 23 | 2. Delete the `examples` folder. 24 | 3. Start writing your game. Your logic should be stored in `lib.rs` (and other files that are pulled in from it). 25 | Then, add all of the plugins and build your `App` in `main.rs`. 26 | 4. If you only care about your game working on `nightly`, remove `stable` from the `toolchain` field in `.github/workflows/ci.yml`. 27 | 28 | If you are making a standalone library: 29 | 30 | 1. Delete `main.rs` and the `[[bin]]` section of the top-level `Cargo.toml`. 31 | 2. Disable `bevy` features: change `default-features` to `false` and disable the `dynamic` feature. This avoids unnecessarily pulling in extra features for your users. 32 | 33 | Finally: 34 | 35 | 1. Rename the lib and bin in `Cargo.toml` (and all imports to ensure your code compiles). 36 | 2. Double check that the LICENSE matches your intent. 37 | 3. Update this README to match your project, modifying `About`, `Getting Started` and other sections as needed. 38 | 4. Consider cleaning up the issue and PR templates found in the `.github` folder to better match your needs. 39 | 40 | ### Running your game 41 | 42 | Use `cargo run`. 43 | This repo is set up to always build with full optimizations, so there's no need for a `--release` flag in most cases. 44 | Dynamic linking is enabled to ensure build times stay snappy. 45 | 46 | To run an example, use `cargo run --example_name`, where `example_name` is the file name of the example without the `.rs` extension. 47 | 48 | ### Publishing your game 49 | 50 | A build will be produced for Windows, MacOS and Linux each time a [tag](https://docs.github.com/en/desktop/contributing-and-collaborating-using-github-desktop/managing-commits/managing-tags) is pushed to GitHub. 51 | 52 | These can be found under the [Releases](https://docs.github.com/en/rest/reference/releases) tab of your project. 53 | 54 | ## Contributing 55 | 56 | See [CONTRIBUTING.md](https://github.com/Leafwing-Studios/template-repo/blob/main/CONTRIBUTING.md)! 57 | 58 | ### Testing 59 | 60 | 1. Use doc tests aggressively to show how APIs should be used. 61 | You can use `#` to hide a setup line from the doc tests. 62 | 2. 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. 63 | 3. Integration tests should be stored in the top level `tests` folder, importing functions from `lib.rs`. 64 | 65 | Use `cargo test` to run all tests. 66 | 67 | ### CI 68 | 69 | The CI will: 70 | 71 | 1. Ensure the code is formatted with `cargo fmt`. 72 | 2. Ensure that the code compiles. 73 | 3. Ensure that (almost) all `clippy` lints pass. 74 | 4. Ensure all tests pass on Windows, MacOS and Ubuntu. 75 | 76 | Check this locally with: 77 | 78 | 1. `cargo run -p ci` 79 | 2. `cargo test --workspace` 80 | 81 | To manually rerun CI: 82 | 83 | 1. Navigate to the `Actions` tab. 84 | 2. Use the dropdown menu in the CI run of interest and select "View workflow file". 85 | 3. In the top-right corner, select "Rerun workflow". 86 | 87 | ### Documentation 88 | 89 | Reference documentation is handled with standard Rust doc strings. 90 | Use `cargo doc --open` to build and then open the docs. 91 | 92 | Design docs (or other book-format documentation) is handled with [mdBook](https://rust-lang.github.io/mdBook/index.html). 93 | Install it with `cargo install mdbook`, then use `mdbook serve --open` to launch the docs. 94 | 95 | ### Benchmarking 96 | 97 | To run the benchmarks, use `cargo bench`. 98 | 99 | For more documentation on making your own benchmarks, check out [criterion's docs](https://bheisler.github.io/criterion.rs/book/index.html). 100 | -------------------------------------------------------------------------------- /design/src/rfc/template.md: -------------------------------------------------------------------------------- 1 | # Feature Name: (fill me in with a unique ident, `my_awesome_feature`) 2 | 3 | ## Summary 4 | 5 | One paragraph explanation of the feature. 6 | 7 | ## Motivation 8 | 9 | Why are we doing this? What use cases does it support, which problems does it solve or what experience does it enable? 10 | 11 | ## User-facing explanation 12 | 13 | Explain the proposal as if it was already included and you were teaching it to a user or player. That generally means: 14 | 15 | - Introducing new named concepts. 16 | - Explaining the feature, ideally through simple examples of solutions to concrete problems. 17 | - Explaining how users should *think* about the feature, and how it should impact the way they use our code or game. It should explain the impact as concretely as possible. 18 | - If applicable, explain how this feature compares to similar existing features, and in what situations the user would use each one. 19 | 20 | ## \[Optional\] Game design analysis 21 | 22 | ### Choices 23 | 24 | - What choices can players make? 25 | - What impact will those choices have? 26 | - Why would different players choose to make different choices? 27 | - Why would the same player choose to make different choices? 28 | - What are the core tensions present in this design? 29 | 30 | ### Feedback loops 31 | 32 | What feedback loops does this design create or build upon? 33 | 34 | ### Tuning levers 35 | 36 | What values or elements of the design can we trivially change after the feature is built to alter power, feel or complexity? 37 | 38 | ### Hooks 39 | 40 | - How can the rest of the game interact with this system? 41 | - How can this system interact with the rest of the game? 42 | 43 | ## Implementation strategy 44 | 45 | This is the technical portion of the RFC. 46 | Try to capture the broad implementation strategy, 47 | and then focus in on the tricky details so that: 48 | 49 | - Its interaction with other features is clear. 50 | - It is reasonably clear how the feature would be implemented. 51 | - Corner cases are dissected by example. 52 | 53 | When necessary, this section should return to the examples given in the previous section and explain the implementation details that make them work. 54 | 55 | When writing this section be mindful of the following: 56 | 57 | - **RFCs should be scoped:** Try to avoid creating RFCs for huge design spaces that span many features. Try to pick a specific feature slice and describe it in as much detail as possible. Feel free to create multiple RFCs if you need multiple features. 58 | - **RFCs should avoid ambiguity:** Two developers implementing the same RFC should come up with nearly identical implementations. 59 | - **RFCs should be "implementable":** Merged RFCs should only depend on features from other merged RFCs and existing features. It is ok to create multiple dependent RFCs, but they should either be merged at the same time or have a clear merge order that ensures the "implementable" rule is respected. 60 | 61 | ## Drawbacks 62 | 63 | - Why should we *not* do this? 64 | - Which technical constraints are we pushing up against? 65 | - Which design constraints are we pushing up against? 66 | - Which product area (art, sound, programming, design, narrative etc.) will this feature tax the most? 67 | 68 | ## Rationale and alternatives 69 | 70 | - Why is this design the best in the space of possible designs? 71 | - What other designs have been considered and what is the rationale for not choosing them? 72 | - What objections immediately spring to mind? How have you addressed them? 73 | - What is the impact of not doing this? 74 | 75 | ## \[Optional\] Prior art 76 | 77 | Discuss prior art, both the good and the bad, in relation to this proposal. 78 | This can include: 79 | 80 | - Does this feature exist in other libraries and what experiences have their community had? 81 | - Papers: Are there any published papers or great posts that discuss this? 82 | 83 | This section is intended to encourage you as an author to think about the lessons from other tools and provide readers of your RFC with a fuller picture. 84 | 85 | Note that while precedent set by other engines is some motivation, it does not on its own motivate an RFC. 86 | 87 | ## Unresolved questions 88 | 89 | - What parts of the design do you expect to resolve through the RFC process before this gets merged? 90 | - What parts of the design do you expect to resolve through the implementation of this feature before the feature PR is merged? 91 | - What related issues do you consider out of scope for this RFC that could be addressed in the future independently of the solution that comes out of this RFC? 92 | - Which questions need to be answered through experimentation before we can commit to this feature? 93 | - What hypotheses do we have? 94 | - What is the simplest, most focused ways we can test each hypothesis? 95 | 96 | ## \[Optional\] Future possibilities 97 | 98 | Think about what the natural extension and evolution of your proposal would 99 | be and how it would affect Bevy as a whole in a holistic way. 100 | Try to use this section as a tool to more fully consider other possible 101 | interactions with the engine in your proposal. 102 | 103 | This is also a good place to "dump ideas", if they are out of scope for the 104 | RFC you are writing but otherwise related. 105 | 106 | Note that having something written down in the future-possibilities section 107 | is not a reason to accept the current or a future RFC; such notes should be 108 | in the section on motivation or rationale in this or subsequent RFCs. 109 | If a feature or change has no direct value on its own, expand your RFC to include the first valuable feature that would build on it. 110 | -------------------------------------------------------------------------------- /LICENSE-APACHE.md: -------------------------------------------------------------------------------- 1 | # Apache License 2 | 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright 2021 Leafwing Studios 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | --------------------------------------------------------------------------------