Sorted out the animation vs. easing contradiction I believe. Now there's a separate easing_duration that's calculated from the total duration of all frames. Then a easing_position determines where in the total the animation is, which is fed to the asing functions as a ration of easing_position / easing_duration.

This commit is contained in:
Zed A. Shaw 2026-02-21 01:57:33 -05:00
parent 0c798c9e0d
commit 1baca783fc
9 changed files with 47 additions and 75 deletions

View file

@ -54,20 +54,11 @@ namespace animator {
}
void FSM::START(Event ev) {
switch(ev) {
case Event::TICK:
state(State::ANIMATE);
break;
default:
state(State::START);
}
state(State::ANIMATE);
}
void FSM::ANIMATE(Event ev) {
switch(ev) {
case Event::TICK:
run_animation();
break;
case Event::PLAY_STOP:
if($anim.playing) {
$anim.stop();
@ -122,7 +113,7 @@ namespace animator {
$anim.play();
}
void FSM::run_animation() {
void FSM::update() {
if($anim.playing) {
$anim.update();
$anim.apply(*$ui.sprite);
@ -131,14 +122,6 @@ namespace animator {
}
}
void FSM::tick() {
auto [ticks, alpha] = $anim.commit();
for(int i = 0; i < ticks; i++) {
event(animator::Event::TICK, {});
}
}
void FSM::check_update() {
if($timer.getElapsedTime().toDuration() > 500ms) {
try {
@ -356,9 +339,9 @@ int main(int argc, char* argv[]) {
main.init(sprite_name, anim_name, background);
while(main.active()) {
main.tick();
main.check_update();
main.update();
main.render();
main.check_update();
main.handle_keyboard_mouse();
}