#gamedev #game-engine #game #anmiation

benimator

A sprite animation library for rust game development

43 releases (23 stable)

4.1.3 Jul 1, 2023
4.1.2 Jan 9, 2023
4.1.0 Oct 11, 2022
4.0.0-alpha.9 Jul 31, 2022
0.3.0 Jul 19, 2021

#253 in Game dev

Download history 17/week @ 2024-07-19 542/week @ 2024-07-26 71/week @ 2024-08-02 39/week @ 2024-08-09 14/week @ 2024-08-16 7/week @ 2024-08-23 12/week @ 2024-08-30 19/week @ 2024-09-06 12/week @ 2024-09-13 95/week @ 2024-09-20 117/week @ 2024-09-27 26/week @ 2024-10-04 16/week @ 2024-10-11 15/week @ 2024-10-18 6/week @ 2024-10-25 15/week @ 2024-11-01

52 downloads per month
Used in bevy_ase

Unlicense OR MIT

44KB
1K SLoC

Benimator

License Crates.io rustc Docs

A sprite animation library for rust game development.

Initially designed for bevy, it is now engine agnostic.

Goals

This project aim to provide the building the blocks to facilitate 2d sprite animation with any game engine.

Non-goals

Benimator is not rendering anything. It only keeps track of sprite indices.

One is expected to use benimator with a game engine such as bevy.

How it looks like

At its core benimator is an Animation data structure and a State to track the frame-index as time pass.

// Create an animation
let animation = Animation::from_indices(0..=3, FrameRate::from_fps(10.0));

// Create a new animation state
let mut state = State::new();

// In the game loop, for each update, tell the state how much time has elapsed
let delta_time = Duration::from_millis(250);
state.update(&animation, delta_time);

// Then get the current frame index.
// (so that we can tell our engine to render the sprite at that index)
assert_eq!(state.frame_index(), 2);

Have a look at the examples for complete examples using the bevy game engine.

Installation

benimator is published on crates.io

You can add the dependency to your cargo file with:

cargo add benimator

Cargo features

Feature Description
serde Implementations of Serialize and Deserialize

Feature flags not mentioned here are NOT part of the public API and are subject to breaking changes!

MSRV

The minimum supported rust version is currently 1.60.

It can be updated to a newer stable version when required, and that will not be considered a breaking change (it can happen in for a minor or patch release).

License

Licensed under either of

at your option.

Dependencies

~175KB