Move the step_animation out of the animate2 module since it's only used in raycaster.cpp.
This commit is contained in:
parent
89ca204f3d
commit
83f62e3f45
3 changed files with 19 additions and 17 deletions
|
|
@ -101,6 +101,20 @@ 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) {
|
||||
auto anim = world.get_if<animate2::Animate2>(entity);
|
||||
|
||||
if(anim != nullptr && anim->playing) {
|
||||
anim->update();
|
||||
anim->apply(sprite);
|
||||
anim->motion(sprite, position, scale);
|
||||
}
|
||||
|
||||
sprite.setScale(scale);
|
||||
sprite.setPosition(position);
|
||||
}
|
||||
|
||||
|
||||
void Raycaster::sprite_casting(sf::RenderTarget &target) {
|
||||
auto& lights = $level.lights->lighting();
|
||||
auto world = $level.world;
|
||||
|
|
@ -202,10 +216,7 @@ void Raycaster::sprite_casting(sf::RenderTarget &target) {
|
|||
effect->setUniform("darkness", level);
|
||||
}
|
||||
|
||||
sf_sprite->setScale(scale);
|
||||
sf_sprite->setPosition(position);
|
||||
|
||||
animate2::step_animation(*world, rec.entity, *sf_sprite);
|
||||
step_animation(*world, rec.entity, *sf_sprite, position, scale);
|
||||
|
||||
sf_sprite->setOrigin(origin);
|
||||
sf_sprite->setTextureRect(in_texture);
|
||||
|
|
@ -215,6 +226,7 @@ void Raycaster::sprite_casting(sf::RenderTarget &target) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void Raycaster::cast_rays() {
|
||||
constexpr static const int texture_width = TEXTURE_WIDTH;
|
||||
constexpr static const int texture_height = TEXTURE_HEIGHT;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue