Animation motion() almost works but need to tweak the calculations so they go for the length of the animation?

This commit is contained in:
Zed A. Shaw 2026-01-21 23:53:13 -05:00
parent 60c405b1fc
commit 31b815d43e
3 changed files with 23 additions and 17 deletions

View file

@ -25,24 +25,27 @@ Animate2 crafter() {
Sequence sequence{
.frames{0,1},
.durations{Random::milliseconds(1, 100), Random::milliseconds(1, 100)}
.durations{Random::milliseconds(33, 100), Random::milliseconds(33, 100)}
};
REQUIRE(sequence.frame_count == sequence.frames.size());
REQUIRE(sequence.frame_count == sequence.durations.size());
Transform transform{
.min_x{1.0f},
.min_y{1.0f},
.max_x{1.0f},
.max_y{1.0f},
.min_x{0.6f},
.min_y{0.6f},
.max_x{0.8f},
.max_y{0.8f},
.simple{true},
.flipped{false},
.ease_rate{0.5f},
.speed{0.1f},
.scaled{false},
.stationary{false},
.stationary{true},
.toggled{false},
.looped{false},
.easing = ease::IN_OUT_BACK,
.motion = ease::RUSH,
};
return {sheet, sequence, transform};
@ -154,8 +157,8 @@ TEST_CASE("confirm transition changes work", "[animation-new]") {
auto anim = crafter();
sf::Vector2f pos{0,0};
sf::Vector2f scale{0,0};
sf::Vector2f pos{10,10};
sf::Vector2f scale{0.6, 0.6};
// also testing that onFrame being null means it's not run
REQUIRE(anim.onFrame == nullptr);
@ -165,10 +168,11 @@ TEST_CASE("confirm transition changes work", "[animation-new]") {
while(anim.playing) {
anim.update();
anim.motion(pos, scale);
fmt::println("POSITION: {},{}; SCALE: {},{}; current: {}; subframe: {}",
pos.x, pos.y, scale.x, scale.y, anim.$sequence.current, anim.$sequence.subframe);
}
REQUIRE(anim.playing == false);
REQUIRE(scale != sf::Vector2f{0,0});
REQUIRE(pos != sf::Vector2f{0,0});
REQUIRE(scale != sf::Vector2f{0,0});
}