diff --git a/assets/animate2.json b/assets/animate2.json index 3124808..119111a 100644 --- a/assets/animate2.json +++ b/assets/animate2.json @@ -6,8 +6,8 @@ "frame_height": 720 }, "sequence": { - "frames": [0, 1, 0, 1], - "durations": [800, 200, 33, 33] + "frames": [0, 1], + "durations": [240, 240] }, "transform": { "min_x": 0.6, diff --git a/tests/animate2.cpp b/tests/animate2.cpp index 64c2cb4..1ced87d 100644 --- a/tests/animate2.cpp +++ b/tests/animate2.cpp @@ -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); diff --git a/tools/animator.cpp b/tools/animator.cpp index e3ab2ce..30bc761 100644 --- a/tools/animator.cpp +++ b/tools/animator.cpp @@ -80,7 +80,7 @@ namespace animator { void FSM::run_animation() { if($anim.playing) { $anim.update(); - $anim.apply(*$sprite); + if(!$anim.transform.simple) $anim.apply(*$sprite); $anim.motion(*$sprite, $pos, $scale); } } @@ -91,8 +91,6 @@ namespace animator { for(int i = 0; i < ticks; i++) { event(animator::Event::TICK, {}); } - - check_update(); } void FSM::check_update() { @@ -189,6 +187,7 @@ int main(int argc, char* argv[]) { while(main.active()) { main.tick(); + main.check_update(); main.render(); main.handle_keyboard_mouse(); }