Animations now have an easing/ease_rate setting that will do a dynamic scaling effect on them during the animation sequence.

This commit is contained in:
Zed A. Shaw 2025-03-01 00:24:19 -05:00
parent 6e363ba78d
commit 033358749f
8 changed files with 42 additions and 14 deletions

View file

@ -151,8 +151,9 @@ void Raycaster::sprite_casting(sf::RenderTarget &target) {
int d = y * texture_height - $height * half_height + sprite_height * half_height;
int tex_y = ((d * texture_height) / sprite_height) / texture_height;
sf::Vector2f origin{texture_width / 2, texture_height / 2};
sf::Vector2f scale{sprite_scale_w, sprite_scale_h};
sf::Vector2f position{x, y};
sf::Vector2f position{x + origin.x * scale.x, y + origin.y * scale.y};
sf::IntRect in_texture{ {tex_x, tex_y}, {tex_render_width, texture_height}};
if($level.world->has<components::Animation>(rec.second)) {
@ -160,6 +161,7 @@ void Raycaster::sprite_casting(sf::RenderTarget &target) {
if(animation.playing) animation.step(scale, in_texture);
}
sf_sprite->setOrigin(origin);
sf_sprite->setScale(scale);
sf_sprite->setTextureRect(in_texture);
sf_sprite->setPosition(position);