Code following Bevy Book
Add bevy
as a dependency
cargo add bevy
Install a faster linker and add configuration files for improving speed.
Install lld
- a faster linker
sudo pacman -S lld
Cargo.toml
[dependencies]
bevy = { version = "0.12.0", features = ["dynamic_linking"] }
# Enable a small amount of optimization in debug mode
[profile.dev]
opt-level = 1
# Enable high optimizations for dependencies (incl. Bevy), but not for our code:
[profile.dev.package."*"]
opt-level = 3
rust-toolchain.toml
[toolchain]
channel = "nightly"
config.toml
# NOTE: For maximum performance, build using a nightly compiler
# If you are using rust stable, remove the "-Zshare-generics=y" below.
[target.x86_64-unknown-linux-gnu]
linker = "clang"
rustflags = ["-Clink-arg=-fuse-ld=lld", "-Zshare-generics=y"]
[target.x86_64-apple-darwin]
rustflags = [
"-C",
"link-arg=-fuse-ld=/usr/local/opt/llvm/bin/ld64.lld",
"-Zshare-generics=y",
]
[target.aarch64-apple-darwin]
rustflags = [
"-C",
"link-arg=-fuse-ld=/opt/homebrew/opt/llvm/bin/ld64.lld",
"-Zshare-generics=y",
]
[target.x86_64-pc-windows-msvc]
linker = "rust-lld.exe"
rustflags = ["-Zshare-generics=n"]
Run
cargo run
It will take a while, since it's compiling a whole game engine.
Subsequent compiles will be iterative and faster.
Continuing Bevy learning with Bevy Examples
Showing chicken running and plants growing using sprite sheet as reference.