From b20b401128a6f95f6291701d30dbc85bda66342c Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Sun, 28 Feb 2010 16:51:24 +0000 Subject: [PATCH] sprite/sprite.cpp: Revert revision 6435 by Mathnerd314. It caused problems for me and lazure reported an identical problem on IRC. SVN-Revision: 6454 --- src/sprite/sprite.cpp | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/src/sprite/sprite.cpp b/src/sprite/sprite.cpp index 16e1adaa0..abf3c93de 100644 --- a/src/sprite/sprite.cpp +++ b/src/sprite/sprite.cpp @@ -87,12 +87,12 @@ Sprite::set_action_continued(const std::string& name) } action = newaction; - while(frame >= get_frames()) { - frame -= get_frames(); - animation_loops--; + if(frame >= get_frames()) { + frame = fmodf(frame, get_frames()); + + if (animation_loops > 0) animation_loops--; if(animation_done()) frame = get_frames()-1; - break; } } @@ -105,22 +105,20 @@ Sprite::animation_done() void Sprite::update() { - if(animation_done()) { - frame = get_frames()-1; + if(animation_done()) return; - } float frame_inc = action->fps * (game_time - last_ticks); last_ticks = game_time; frame += frame_inc; - while(frame >= get_frames()) { - frame -= get_frames(); + if(frame >= get_frames()) { + frame = fmodf(frame, get_frames()); + animation_loops--; if(animation_done()) frame = get_frames()-1; - break; } } @@ -132,7 +130,7 @@ Sprite::draw(DrawingContext& context, const Vector& pos, int layer, update(); if((int)frame >= get_frames() || (int)frame < 0) - log_warning << "frame out of range: " << frame << "/" << get_frames() << " at " << get_name() << "/" << get_action() << std::endl; + log_warning << "frame out of range: " << (int)frame << "/" << get_frames() << " at " << get_name() << "/" << get_action() << std::endl; else { context.set_drawing_effect(effect); context.draw_surface(action->surfaces[(int)frame], @@ -169,7 +167,7 @@ Sprite::get_width() const { if((int)frame >= get_frames() || (int)frame < 0) { - log_warning << "frame out of range: " << frame << "/" << get_frames() << " at " << get_name() << "/" << get_action() << std::endl; + log_warning << "frame out of range: " << (int)frame << "/" << get_frames() << " at " << get_name() << "/" << get_action() << std::endl; return 0; } else @@ -183,7 +181,7 @@ Sprite::get_height() const { if((int)frame >= get_frames() || (int)frame < 0) { - log_warning << "frame out of range: " << frame << "/" << get_frames() << " at " << get_name() << "/" << get_action() << std::endl; + log_warning << "frame out of range: " << (int)frame << "/" << get_frames() << " at " << get_name() << "/" << get_action() << std::endl; return 0; } else -- 2.11.0