Baffled by quaternions? Want to accelerate an object in 2D? Wish that there was a simple way to work with grids? Just want to know if two axis-aligned bounding boxes intersect?
Try out leafwing_2d
: a flexible, ergonomics-first solution!
Features:
Position<C: Coordinate>
type for working with 2D coordinates
DiscreteCoordinate
trait for important grid-based tasks like finding neighboursDirection
(unit vector) and Rotation
(angle from midnight) types instead!
Orientation::orientation_to
and Rotation::towards
DirectionPartitioning
traitLeafwingSpriteBundle
and the Scale
type.
AxisAlignedBoundingBox
type.TwoDPlugin
to automatically synchronize your Transforms
with Position
, Direction
and Rotation
, but modify whichever one you'd likeVelocity<C>
, Acceleration<C>
and their angular analoguesPositionlike
trait#![forbid(missing_docs)]
leafwing_2d
to your Cargo.toml
.C
.
f32
) or integer (e.g. u8
or i64
) types work.DiscreteCoordinate
types like OrthogonalGrid
)!TwoDBundle
bundle to your entities, or toss on a Position
, Direction
or Rotation
component.TwoDPlugin
to your App
to synchronize these easy-to-work with 2D geometry types with Bevy's Transform
.To run an example, use cargo run --example_name
, where example_name
is the file name of the example without the .rs
extension.
This repository is open to community contributions! There are a few options if you'd like to help:
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.
#
to hide a setup line from the doc tests.#[cfg(test)]
on the test module to ignore it during builds, and #[test]
on the test functions to ensure they are run.tests
folder, importing functions from lib.rs
.Use cargo test
to run all tests.
The CI will:
cargo fmt
.clippy
lints pass.Check this locally with:
cargo run -p ci
cargo test --workspace
To manually rerun CI:
Actions
tab.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.