Animations are now being pulled correctly but I need to add a timing concept to animations instead of ticks.

This commit is contained in:
Zed A. Shaw 2025-10-10 00:25:37 -04:00
parent 517de91a5b
commit c33f370572
10 changed files with 43 additions and 22 deletions

View file

@ -31,6 +31,9 @@ namespace components {
}
void Animation::step(sf::Vector2f& scale_out, sf::Vector2f& pos_out, sf::IntRect& rect_out) {
dbc::check(rect_out.size.x > 0, "invalid frame width in animation");
dbc::check(rect_out.size.y > 0, "invalid frame height in animation");
if(playing && current < frames) {
float tick = twitching();
scale_out.x = std::lerp(scale_out.x, scale_out.x + scale, tick);
@ -70,10 +73,9 @@ namespace animation {
static AnimationManager MGR;
static bool initialized = false;
bool apply(Animation& anim, sf::Sprite& sprite) {
bool apply(Animation& anim, sf::Sprite& sprite, sf::Vector2f pos) {
sf::IntRect rect{{0,0}, {anim.frame_width, anim.frame_height}};
sf::Vector2f scale{anim.scale, anim.scale};
sf::Vector2f pos{0, 0};
anim.step(scale, pos, rect);
@ -156,5 +158,4 @@ namespace animation {
animation.play();
}
}
}