diff --git a/animation.cpp b/animation.cpp index 56f20f6..fd1333e 100644 --- a/animation.cpp +++ b/animation.cpp @@ -50,6 +50,7 @@ namespace animation { dbc::check(sequence.current < $frame_rects.size(), "current frame past $frame_rects"); // NOTE: pos is not updated yet auto& rect = $frame_rects.at(sequence.current); + fmt::println("setting texture rect: {},{}", rect.position.x, rect.position.y); sprite.setTextureRect(rect); } diff --git a/assets/animation.json b/assets/animation.json index 8494153..8f91b49 100644 --- a/assets/animation.json +++ b/assets/animation.json @@ -308,17 +308,17 @@ }, "transforms": { "basic": { - "min_x": 1.0, - "min_y": 1.0, + "min_x": 0.9, + "min_y": 0.9, "max_x": 1.0, "max_y": 1.0, "flipped": false, - "scaled": false, + "scaled": true, "toggled": false, - "looped": false, + "looped": true, "relative": false, - "easing": "none", - "motion": "move_none" + "easing": "sine", + "motion": "move_rush" } }, "forms": { @@ -337,21 +337,21 @@ "frame_height": 256 }, "sequences": { - "idle": {"frames": [0], "durations": [5] } + "idle": {"frames": [0], "durations": [20] } }, "transforms": { "basic": { - "min_x": 1.0, - "min_y": 1.0, + "min_x": 0.9, + "min_y": 0.9, "max_x": 1.0, "max_y": 1.0, "flipped": false, - "scaled": false, + "scaled": true, "toggled": false, - "looped": false, + "looped": true, "relative": false, - "easing": "none", - "motion": "move_none" + "easing": "sine", + "motion": "move_rush" } }, "forms": { @@ -374,17 +374,17 @@ }, "transforms": { "basic": { - "min_x": 1.0, - "min_y": 1.0, + "min_x": 0.9, + "min_y": 0.9, "max_x": 1.0, "max_y": 1.0, "flipped": false, - "scaled": false, + "scaled": true, "toggled": false, - "looped": false, + "looped": true, "relative": false, - "easing": "none", - "motion": "move_none" + "easing": "sine", + "motion": "move_rush" } }, "forms": { @@ -407,17 +407,17 @@ }, "transforms": { "basic": { - "min_x": 1.0, - "min_y": 1.0, + "min_x": 0.9, + "min_y": 0.9, "max_x": 1.0, "max_y": 1.0, "flipped": false, - "scaled": false, + "scaled": true, "toggled": false, - "looped": false, + "looped": true, "relative": false, - "easing": "none", - "motion": "move_none" + "easing": "sine", + "motion": "move_rush" } }, "forms": { @@ -440,17 +440,17 @@ }, "transforms": { "basic": { - "min_x": 1.0, - "min_y": 1.0, + "min_x": 0.9, + "min_y": 0.9, "max_x": 1.0, "max_y": 1.0, "flipped": false, - "scaled": false, + "scaled": true, "toggled": false, - "looped": false, + "looped": true, "relative": false, - "easing": "none", - "motion": "move_none" + "easing": "sine", + "motion": "move_rush" } }, "forms": { diff --git a/raycaster.cpp b/raycaster.cpp index 30a5df8..1163834 100644 --- a/raycaster.cpp +++ b/raycaster.cpp @@ -101,17 +101,22 @@ void Raycaster::apply_sprite_effect(shared_ptr effect, float width, effect->setUniform("u_resolution", u_resolution); } -inline void step_animation(DinkyECS::World& world, DinkyECS::Entity entity, sf::Sprite& sprite, sf::Vector2f& position, sf::Vector2f& scale) { +inline void step_animation(DinkyECS::World& world, DinkyECS::Entity entity, sf::Sprite& sprite, sf::Vector2f& position, sf::Vector2f& scale, sf::IntRect& in_texture, sf::Vector2f& origin) { auto anim = world.get_if(entity); if(anim != nullptr && anim->playing) { anim->update(); anim->apply(sprite); anim->motion(sprite, position, scale); + + auto& old_rect = sprite.getTextureRect(); + in_texture.position.x += old_rect.position.x; } sprite.setScale(scale); sprite.setPosition(position); + sprite.setOrigin(origin); + sprite.setTextureRect(in_texture); } @@ -216,10 +221,7 @@ void Raycaster::sprite_casting(sf::RenderTarget &target) { effect->setUniform("darkness", level); } - step_animation(*world, rec.entity, *sf_sprite, position, scale); - - sf_sprite->setOrigin(origin); - sf_sprite->setTextureRect(in_texture); + step_animation(*world, rec.entity, *sf_sprite, position, scale, in_texture, origin); target.draw(*sf_sprite, effect.get()); }