Added invariants to the Sequence to hunt down a bug in the tests but I'll leave it there for future testing.
This commit is contained in:
parent
1baca783fc
commit
d56b4bd335
4 changed files with 44 additions and 18 deletions
|
|
@ -22,7 +22,11 @@ Animate2 load_animation(const string& name) {
|
|||
anim.set_form("attack");
|
||||
|
||||
anim.transform.looped = false;
|
||||
anim.sequence.durations = {Random::uniform(1, 5), Random::uniform(1, 5)};
|
||||
|
||||
for(size_t i = 0; i < anim.sequence.durations.size(); i++) {
|
||||
anim.sequence.durations[i] = Random::uniform(1, 5);
|
||||
}
|
||||
|
||||
return anim;
|
||||
}
|
||||
|
||||
|
|
@ -61,6 +65,12 @@ TEST_CASE("new animation system", "[animation-new]") {
|
|||
auto anim = load_animation("rat_king_boss");
|
||||
PLAY_TEST(anim);
|
||||
|
||||
// test that toggled works
|
||||
anim.transform.toggled = true;
|
||||
PLAY_TEST(anim);
|
||||
REQUIRE(anim.sequence.current == anim.sequence.frames.size() - 1);
|
||||
anim.transform.toggled = false;
|
||||
|
||||
bool onLoop_ran = false;
|
||||
anim.onLoop = [&](auto& seq, auto& tr) -> bool {
|
||||
seq.current = 0;
|
||||
|
|
@ -84,16 +94,6 @@ TEST_CASE("new animation system", "[animation-new]") {
|
|||
|
||||
PLAY_TEST(anim);
|
||||
REQUIRE(anim.sequence.loop_count == 2);
|
||||
|
||||
// stops at end
|
||||
anim.onLoop = [](auto& seq, auto& tr) -> bool {
|
||||
if(seq.loop_count == 1) {
|
||||
seq.current = seq.frame_count - 1;
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue