TheSeekerGame / TheSeeker

Metroidvania game in Bevy
68 stars 15 forks source link

WIP: scriptable sprite animation system + assets #2

Closed inodentry closed 8 months ago

inodentry commented 1 year ago

Sprite animations can be defined using asset files (probably in RON format).

The Animation Asset Format

Settings

There is a settings header, which specifies general parameters for "simple animations": start frame, end frame, ticks per frame (playback speed). An "absolute tick mode" is also supported, for animations that should be timed from when the player entered a level/room, rather than when the animation entity was spawned.

Such a simple animation will just play from the start frame to the end frame, at the given rate, and stop. For more complex behaviors (such as looping), use "scripts".

Scripts

The animation file can also contain optional scripts, which are actions to perform at given times (on a given tick, on a given frame index, etc.). This allows complex behaviors to be attached to the animation.

In this PR, we only support some simple script actions:

In the future, we can add more complex actions for advanced workflows:

By the end of this all, we should have something that roughly feels like working in a dynamically scriptable game engine, driven by animations and powered by Bevy and Rust. ;)

The Animation Player Implementation

Entities that play sprite animations should have a SpriteAnimationPlayer component, which holds the internal data for animation playback. Animations can be started by calling the .play(...) method. This is similar to Bevy's (general) animations API.

Every Bevy update (not fixed update), the update system runs and will do what it has to do to "catch up" to the current tick: run scripts for any ticks that have elapsed, advance frames, run scripts for animation frames, ...

Playback can be paused. There are two "pause modes":

Please give feedback! 😊

inodentry commented 8 months ago

Closing, this PR is old/stale. We have another implementation of this idea already in the codebase.