Fixed a test that failed because loop was set on the tranform being used.

This commit is contained in:
Zed A. Shaw 2026-02-03 22:34:19 -05:00
parent c092b82dfc
commit ce3d142208
3 changed files with 15 additions and 9 deletions

View file

@ -15,11 +15,19 @@ using namespace textures;
using namespace std::chrono_literals;
using namespace animate2;
Animate2 load_animation(const string& name) {
auto anim = animate2::load("assets/animate2.json", "rat_king_boss");
anim.transform.looped = false;
anim.sequence.durations = {Random::milliseconds(5, 33), Random::milliseconds(5, 33)};
return anim;
}
void FAKE_RENDER() {
std::this_thread::sleep_for(Random::milliseconds(5, 32));
}
void PLAY_TEST(Animate2 &anim) {
REQUIRE(anim.transform.looped == false);
anim.play();
while(anim.playing) {
@ -44,8 +52,7 @@ void PLAY_TEST(Animate2 &anim) {
TEST_CASE("new animation system", "[animation-new]") {
textures::init();
auto anim = animate2::load("assets/animate2.json", "rat_king_boss");
anim.sequence.durations = {Random::milliseconds(5, 33), Random::milliseconds(5, 33)};
auto anim = load_animation("rat_king_boss");
PLAY_TEST(anim);
bool onLoop_ran = false;
@ -88,7 +95,7 @@ TEST_CASE("confirm frame sequencing works", "[animation-new]") {
textures::init();
animation::init();
auto anim = animate2::load("assets/animate2.json", "rat_king_boss");
auto anim = load_animation("rat_king_boss");
auto boss = textures::get_sprite("rat_king_boss");
sf::IntRect init_rect{{0,0}, {anim.sheet.frame_width, anim.sheet.frame_height}};
@ -129,7 +136,7 @@ TEST_CASE("confirm transition changes work", "[animation-new]") {
sf::Vector2f pos{100,100};
sprite.setPosition(pos);
auto scale = sprite.getScale();
auto anim = animate2::load("assets/animate2.json", "rat_king_boss");
auto anim = load_animation("rat_king_boss");
// also testing that onFrame being null means it's not run
REQUIRE(anim.onFrame == nullptr);