diff options
author | Paweł Redman <pawel.redman@gmail.com> | 2017-12-15 18:11:02 +0100 |
---|---|---|
committer | Paweł Redman <pawel.redman@gmail.com> | 2017-12-15 18:11:02 +0100 |
commit | d1ea04251bf5f77a0eeda2ce1247a17c19556a6c (patch) | |
tree | c17bf8eb9a821dd2fd7c4e20344edee0ea0b04c6 /src/render.cpp | |
parent | 4dd7ac29fe0132b9f5896a84ccfe8d05363dfa74 (diff) |
Explicit phase control for animated textures.
Diffstat (limited to 'src/render.cpp')
-rw-r--r-- | src/render.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
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, |