diff --git a/tools/animator.cpp b/tools/animator.cpp index 1ce2a67..7ac0b7e 100644 --- a/tools/animator.cpp +++ b/tools/animator.cpp @@ -14,6 +14,8 @@ #include "gui/guecstra.hpp" #include "animate2.hpp" +using namespace std::chrono_literals; + bool YES_SYNC=true; namespace animator { @@ -141,6 +143,35 @@ namespace animator { }; } +animate2::Sheet sheet{ + .width{720*2}, + .height{720}, + .frame_width{720}, + .frame_height{720}, +}; + +animate2::Sequence sequence{ + .frames{0,1}, + .durations{166ms, 266ms} +}; + +animate2::Transform transform{ + .min_x{0.6f}, + .min_y{0.6f}, + .max_x{0.8f}, + .max_y{0.8f}, + .simple{false}, + .flipped{false}, + .ease_rate{0.5f}, + .speed{0.02f}, + .scaled{true}, + .stationary{true}, + .toggled{false}, + .looped{true}, + .easing = ease2::in_out_back, + .motion = ease2::move_rush, +}; + int main(int argc, char* argv[]) { shaders::init(); components::init(); @@ -158,19 +189,29 @@ int main(int argc, char* argv[]) { animator::FSM main; main.init(argv[1]); + animate2::Animate2 anim{sheet, sequence, transform}; animate2::Timer timer; timer.start(); + anim.play(); + + auto viewer = main.$ui.$ui.entity("viewer"); + auto& sprite = main.$ui.$ui.get(viewer).sprite; while(main.active()) { timer.begin(); + + anim.apply(*sprite); main.render(); + auto [ticks, alpha] = timer.commit(); fmt::println("TICK: {}, alpha: {}", ticks, alpha); for(int i = 0; i < ticks; i++) { main.event(game::Event::TICK, {}); + anim.update(); } + // do something with alpha.... main.handle_keyboard_mouse(); }