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
|
|
@ -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