Created a nice utility library for doing animations, and used it in the ritual crafting UI.
This commit is contained in:
parent
0a40135f5d
commit
1aa6674e42
14 changed files with 213 additions and 150 deletions
53
tests/animation.cpp
Normal file
53
tests/animation.cpp
Normal file
|
@ -0,0 +1,53 @@
|
|||
#include <catch2/catch_test_macros.hpp>
|
||||
#include "animation.hpp"
|
||||
#include "dinkyecs.hpp"
|
||||
#include "config.hpp"
|
||||
#include <iostream>
|
||||
|
||||
using namespace components;
|
||||
using namespace textures;
|
||||
|
||||
TEST_CASE("animation easing tests", "[animation]") {
|
||||
Animation anim;
|
||||
|
||||
anim.easing = ease::NONE;
|
||||
float res = anim.twitching();
|
||||
REQUIRE(res == 0.0);
|
||||
|
||||
anim.easing = ease::SINE;
|
||||
anim.subframe = 1.0f;
|
||||
res = anim.twitching();
|
||||
REQUIRE(!std::isnan(res));
|
||||
|
||||
anim.easing = ease::OUT_CIRC;
|
||||
res = anim.twitching();
|
||||
REQUIRE(!std::isnan(res));
|
||||
|
||||
anim.easing = ease::OUT_BOUNCE;
|
||||
res = anim.twitching();
|
||||
REQUIRE(!std::isnan(res));
|
||||
|
||||
anim.easing = ease::IN_OUT_BACK;
|
||||
res = anim.twitching();
|
||||
REQUIRE(!std::isnan(res));
|
||||
|
||||
anim.easing = ease::FUCKFACE;
|
||||
bool throws = false;
|
||||
try { anim.twitching(); } catch(...) { throws = true; }
|
||||
REQUIRE(throws);
|
||||
}
|
||||
|
||||
|
||||
TEST_CASE("animation utility API", "[animation]") {
|
||||
textures::init();
|
||||
animation::init();
|
||||
|
||||
auto blanket = textures::get("ritual_crafting_area");
|
||||
auto anim = animation::load("ritual_blanket");
|
||||
|
||||
anim.play();
|
||||
|
||||
while(animation::apply(anim, blanket)) {
|
||||
fmt::println("animation: {}", anim.subframe);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue