diff --git a/Makefile b/Makefile index dfbae2d..d33154a 100644 --- a/Makefile +++ b/Makefile @@ -78,7 +78,7 @@ story: gdb --nx -x .gdbinit --batch --ex run --ex bt --ex q --args ./builddir/storyboard debug_animator: - gdb --nx -x .gdbinit --batch --ex run --ex bt --ex q --args ./builddir/animator.exe -s "rat_king_boss" -a "rat_king_boss" -b "test_background" + gdb --nx -x .gdbinit --batch --ex run --ex bt --ex q --args ./builddir/animator -s "rat_king_boss" -a "rat_king_boss" -b "test_background" animator: ./builddir/animator.exe -s "rat_king_boss" -a "rat_king_boss" -b "test_background" diff --git a/animate2.cpp b/animate2.cpp index 31cdcc3..c056a07 100644 --- a/animate2.cpp +++ b/animate2.cpp @@ -86,7 +86,11 @@ namespace animate2 { } else { sequence.timer.restart(); sequence.current++; - if(sequence.subframe > SUB_FRAME_SENSITIVITY) sequence.subframe = 0.0f; + + if(sequence.subframe > SUB_FRAME_SENSITIVITY) { + sequence.subframe = 0.0f; + } + frame_change = true; } diff --git a/boss/fight.cpp b/boss/fight.cpp index 94f6f3c..a7a5ead 100644 --- a/boss/fight.cpp +++ b/boss/fight.cpp @@ -41,8 +41,6 @@ namespace boss { using enum game::Event; switch(ev) { - // this is only if using the debug X key to skip it - case TICK: case BOSS_START: $ui.status(L"PLAYER REQUESTS", L"COMMIT"); $battle.ap_refresh(); @@ -177,7 +175,6 @@ namespace boss { $ui.animate_actor("player"); break; } - } void Fight::run_systems() { diff --git a/scene.cpp b/scene.cpp index ed2fd6a..5c3f6b7 100644 --- a/scene.cpp +++ b/scene.cpp @@ -127,7 +127,9 @@ namespace scene { void Engine::play_animations() { for(auto& fixture : $fixtures) { if(fixture.anim.playing) { + fixture.anim.update(); fixture.anim.apply(*fixture.st.sprite); + // REFACTOR: fixture.anim.apply(*fixture.st.sprite); } else { fixture.effect = nullptr; } @@ -135,9 +137,10 @@ namespace scene { for(auto& actor : $actors) { if(actor.anim.playing) { + actor.anim.update(); actor.anim.apply(*actor.st.sprite); // REFACTOR: actor.anim.apply(actor.text, actor.pos); - if(actor.effect != nullptr) actor.anim.apply_effect(actor.effect); + // if(actor.effect != nullptr) actor.anim.apply_effect(actor.effect); } else { actor.effect = nullptr; } @@ -173,13 +176,22 @@ namespace scene { } void Engine::set_end_cb(std::function cb) { - // REFACTOR: - // for(auto& actor : $actors) { - // actor.anim.end_cb = cb; - // } + for(auto& actor : $actors) { + actor.anim.onLoop = [&](auto& seq, auto& tr) -> bool { + seq.current = tr.toggled ? seq.frame_count - 1 : 0; + cb(); + return tr.looped; + }; + } } void Engine::reset(sf::RenderTexture& view) { $camera.reset(view); } + + void Engine::tick() { + for(auto& actor : $actors) { + auto [ticks, alpha] = actor.anim.commit(); + } + } } diff --git a/scene.hpp b/scene.hpp index 02360e3..261ed46 100644 --- a/scene.hpp +++ b/scene.hpp @@ -58,5 +58,6 @@ namespace scene { void zoom(float mid_x, float mid_y, const std::string& style, float scale); void reset(sf::RenderTexture& view); void set_end_cb(std::function cb); + void tick(); }; } diff --git a/tools/animator.cpp b/tools/animator.cpp index a53b5c1..751d0bf 100644 --- a/tools/animator.cpp +++ b/tools/animator.cpp @@ -312,12 +312,12 @@ int error_usage() { } int main(int argc, char* argv[]) { - shaders::init(); + ai::init("ai"); + animation::init(); components::init(); sfml::Backend backend; guecs::init(&backend); - ai::init("ai"); - animation::init(); + shaders::init(); std::string sprite_name; std::string background; diff --git a/tools/arena.cpp b/tools/arena.cpp index e13b804..0678f83 100644 --- a/tools/arena.cpp +++ b/tools/arena.cpp @@ -50,13 +50,14 @@ int main(int, char*[]) { dbc::check(main->$world == world, "GameDB::current_world doesn't match boss fight world."); while(!main->in_state(boss::State::END)) { + main->$ui.$arena.tick(); + main->render(window); + if(main->handle_keyboard_mouse() || main->handle_world_events()) { return 0; } - - main->render(window); window.display(); }