benimator/lib.rs
1#![warn(
2    future_incompatible,
3    nonstandard_style,
4    rust_2018_idioms,
5    missing_docs,
6    clippy::pedantic
7)]
8#![cfg_attr(test, allow(clippy::needless_pass_by_value))]
9#![cfg_attr(nightly, feature(doc_auto_cfg))]
10
11//! A sprite animation library for rust game development
12//!
13//! Initially designed for [bevy], it is now engine agnostic.                       
14//!
15//! # Get started
16//!
17//! benimator assumes usage of texture atlas (or equivalent).
18//!
19//! An [`Animation`] contains the list of animation frames,
20//! each frame defined by an index.
21//!
22//! ```
23//! # use std::time::Duration;
24//! use benimator::*;
25//!
26//! // Create an animation
27//! let animation = Animation::from_indices(0..=3, FrameRate::from_fps(10.0));
28//!
29//! // Create a new animation state
30//! let mut state = State::new();
31//!
32//! // In the game loop, for each update, tell the state how much time has elapsed
33//! let delta_time = Duration::from_millis(250);
34//! state.update(&animation, delta_time);
35//!
36//! // Then get the current frame index.
37//! // (so that we can tell our engine to render the sprite at that index)
38//! assert_eq!(state.frame_index(), 2);
39//! ```
40//!
41//! Have a look at the [examples](https://github.com/jcornaz/benimator/tree/main/examples) for complete examples using the [bevy] game engine.
42//!
43//! [bevy]: https://bevyengine.org
44
45#[cfg(test)]
46#[macro_use]
47extern crate rstest;
48
49pub use animation::{Animation, Frame, FrameRate};
50pub use state::State;
51
52mod animation;
53mod state;