Animations are working better in the raycaster but still need refinement.
This commit is contained in:
parent
81a282d544
commit
cded8a937e
3 changed files with 39 additions and 36 deletions
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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": {
|
||||
|
|
|
|||
|
|
@ -101,17 +101,22 @@ void Raycaster::apply_sprite_effect(shared_ptr<sf::Shader> 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<animation::Animation>(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());
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue