From d1ea04251bf5f77a0eeda2ce1247a17c19556a6c Mon Sep 17 00:00:00 2001 From: Paweł Redman Date: Fri, 15 Dec 2017 18:11:02 +0100 Subject: Explicit phase control for animated textures. --- src/render.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/render.cpp') diff --git a/src/render.cpp b/src/render.cpp index a7c6ba6..0e04aab 100644 --- a/src/render.cpp +++ b/src/render.cpp @@ -144,7 +144,7 @@ void state_t::render(game::state_t *game) } } -void state_t::render(animated_texture_t *anim, rectf_t bounds, bool mirror){ +void state_t::render(double phase, animated_texture_t *anim, rectf_t bounds, bool mirror){ size_t frame; if (!anim) @@ -153,7 +153,7 @@ void state_t::render(animated_texture_t *anim, rectf_t bounds, bool mirror){ if (!anim->frame_count) return; - frame = floor(fmod(now * 20.0, anim->frame_count)); + frame = floor(fmod(phase, 1.0) * anim->frame_count); wot_rect.setTexture(anim->frames + frame, true); wot_rect.setFillColor(sf::Color::White); @@ -173,13 +173,13 @@ void state_t::render(animated_texture_t *anim, rectf_t bounds, bool mirror){ wot_rect.setScale(v2f_t(1, 1)); } -void state_t::render(oriented_sprite_t *sprite, rectf_t bounds, float angle) +void state_t::render(double phase, oriented_sprite_t *sprite, rectf_t bounds, float angle) { size_t index; bool mirror; index = sprite->select_index(angle, &mirror); - render(sprite->textures + index, bounds, mirror); + render(phase, sprite->textures + index, bounds, mirror); } void state_t::render_text(v2f_t x, float height, std::string str, -- cgit