Move the step_animation out of the animate2 module since it's only used in raycaster.cpp.

This commit is contained in:
Zed A. Shaw 2026-02-24 11:14:16 -05:00
parent 89ca204f3d
commit 83f62e3f45
3 changed files with 19 additions and 17 deletions

View file

@ -289,17 +289,10 @@ namespace animate2 {
} }
} }
void step_animation(DinkyECS::World& world, DinkyECS::Entity entity, sf::Sprite& sprite) {
if(auto anim = world.get_if<Animate2>(entity)) {
if(anim->playing) {
anim->update();
anim->apply(sprite);
}
}
}
void animate_entity(DinkyECS::World &world, DinkyECS::Entity entity) { void animate_entity(DinkyECS::World &world, DinkyECS::Entity entity) {
if(auto anim = world.get_if<Animate2>(entity)) { auto anim = world.get_if<Animate2>(entity);
if(anim != nullptr && !anim->playing) {
anim->play(); anim->play();
} }
} }

View file

@ -138,11 +138,8 @@ namespace animate2 {
void configure(DinkyECS::World& world, DinkyECS::Entity entity); void configure(DinkyECS::World& world, DinkyECS::Entity entity);
void step_animation(DinkyECS::World& world, DinkyECS::Entity entity, sf::Sprite& sprite);
void animate_entity(DinkyECS::World &world, DinkyECS::Entity entity); void animate_entity(DinkyECS::World &world, DinkyECS::Entity entity);
ENROLL_COMPONENT(Sheet, frames, frame_width, frame_height); ENROLL_COMPONENT(Sheet, frames, frame_width, frame_height);
ENROLL_COMPONENT(Sequence, frames, durations); ENROLL_COMPONENT(Sequence, frames, durations);
ENROLL_COMPONENT(Transform, min_x, min_y, max_x, max_y, ENROLL_COMPONENT(Transform, min_x, min_y, max_x, max_y,

View file

@ -101,6 +101,20 @@ void Raycaster::apply_sprite_effect(shared_ptr<sf::Shader> effect, float width,
effect->setUniform("u_resolution", u_resolution); 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) { void Raycaster::sprite_casting(sf::RenderTarget &target) {
auto& lights = $level.lights->lighting(); auto& lights = $level.lights->lighting();
auto world = $level.world; auto world = $level.world;
@ -202,10 +216,7 @@ void Raycaster::sprite_casting(sf::RenderTarget &target) {
effect->setUniform("darkness", level); effect->setUniform("darkness", level);
} }
sf_sprite->setScale(scale); step_animation(*world, rec.entity, *sf_sprite, position, scale);
sf_sprite->setPosition(position);
animate2::step_animation(*world, rec.entity, *sf_sprite);
sf_sprite->setOrigin(origin); sf_sprite->setOrigin(origin);
sf_sprite->setTextureRect(in_texture); sf_sprite->setTextureRect(in_texture);
@ -215,6 +226,7 @@ void Raycaster::sprite_casting(sf::RenderTarget &target) {
} }
} }
void Raycaster::cast_rays() { void Raycaster::cast_rays() {
constexpr static const int texture_width = TEXTURE_WIDTH; constexpr static const int texture_width = TEXTURE_WIDTH;
constexpr static const int texture_height = TEXTURE_HEIGHT; constexpr static const int texture_height = TEXTURE_HEIGHT;