diff --git a/assets/animate2.json b/assets/animate2.json index 85976d6..9b3124a 100644 --- a/assets/animate2.json +++ b/assets/animate2.json @@ -61,5 +61,73 @@ "attack": [[0, "Sword_Hit_1"], [1, "Marmot_Scream_1"]], "hurt": [[1, "Marmot_Scream_1"]] } + }, + "peasant_girl_rear_view": { + "sheet": { + "frames": 1, + "frame_width": 400, + "frame_height": 540 + }, + "sequences": { + "idle": {"frames": [0], "durations": [800] }, + "hurt": {"frames": [0], "durations": [800] }, + "attack": {"frames": [0], "durations": [800] } + }, + "transforms": { + "breathe": { + "min_x": 0, + "min_y": 0, + "max_x": 0, + "max_y": -10, + "flipped": false, + "ease_rate": 3.0, + "scaled": false, + "toggled": false, + "looped": true, + "easing": "sine", + "motion": "move_bounce" + } + }, + "forms": { + "idle": ["idle", "breathe"], + "attack": ["attack", "breathe"], + "hurt": ["hurt", "breathe"] + }, + "sounds": { + "idle": [], + "attack": [], + "hurt": [] + } + }, + "torch_fixture": { + "sheet": { + "frames": 3, + "frame_width": 256, + "frame_height": 256 + }, + "sequences": { + "idle": {"frames": [0,1,2], "durations": [100, 100, 100] } + }, + "transforms": { + "render": { + "min_x": 0, + "min_y": 0, + "max_x": 0, + "max_y": 0, + "flipped": false, + "ease_rate": 3.0, + "scaled": false, + "toggled": false, + "looped": true, + "easing": "sine", + "motion": "move_none" + } + }, + "forms": { + "idle": ["idle", "render"] + }, + "sounds": { + "idle": [] + } } } diff --git a/ease2.cpp b/ease2.cpp index adc6163..7e08149 100644 --- a/ease2.cpp +++ b/ease2.cpp @@ -106,6 +106,7 @@ namespace ease2 { {"in_out_back", in_out_back}, {"random", random}, {"normal_dist", normal_dist}, + {"none", none}, }; std::unordered_map map_of_motions{ diff --git a/scene.cpp b/scene.cpp index 5a2ca70..ed2fd6a 100644 --- a/scene.cpp +++ b/scene.cpp @@ -1,5 +1,5 @@ #include "scene.hpp" -#include "animation.hpp" +#include "animate2.hpp" #include #include "shaders.hpp" #include @@ -19,8 +19,8 @@ namespace scene { bool flipped = config["flipped"]; // BUG: need to make animation optional - auto anim = animation::load(sprite_name); - anim.flipped = flipped; + auto anim = animate2::load("./assets/animate2.json", sprite_name); + anim.transform.flipped = flipped; if(and_play) anim.play(); std::string cell = config["cell"]; @@ -127,7 +127,7 @@ namespace scene { void Engine::play_animations() { for(auto& fixture : $fixtures) { if(fixture.anim.playing) { - fixture.anim.apply(*fixture.st.sprite, fixture.pos); + fixture.anim.apply(*fixture.st.sprite); } else { fixture.effect = nullptr; } @@ -135,13 +135,9 @@ namespace scene { for(auto& actor : $actors) { if(actor.anim.playing) { - actor.anim.apply(*actor.st.sprite, actor.pos); - actor.anim.apply(actor.text, actor.pos); - if(actor.effect) { - actor.effect->setUniform("u_time", $clock.getElapsedTime().asSeconds()); - sf::Vector2f u_resolution{float(actor.anim.frame_width), float(actor.anim.frame_height)}; - actor.effect->setUniform("u_resolution", u_resolution); - } + actor.anim.apply(*actor.st.sprite); + // REFACTOR: actor.anim.apply(actor.text, actor.pos); + if(actor.effect != nullptr) actor.anim.apply_effect(actor.effect); } else { actor.effect = nullptr; } @@ -177,9 +173,10 @@ namespace scene { } void Engine::set_end_cb(std::function cb) { - for(auto& actor : $actors) { - actor.anim.end_cb = cb; - } + // REFACTOR: + // for(auto& actor : $actors) { + // actor.anim.end_cb = cb; + // } } void Engine::reset(sf::RenderTexture& view) { diff --git a/scene.hpp b/scene.hpp index ea793c8..02360e3 100644 --- a/scene.hpp +++ b/scene.hpp @@ -2,12 +2,12 @@ #include #include -#include "components.hpp" #include "textures.hpp" #include #include #include "camera.hpp" #include +#include "animate2.hpp" namespace scene { using std::shared_ptr; @@ -16,7 +16,7 @@ namespace scene { struct Element { std::string name; textures::SpriteTexture st; - components::Animation anim; + animate2::Animate2 anim; std::string cell; float scale_x = 1.0f; float scale_y = 1.0f;