X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=lib%2Fspecial%2Fsprite.cpp;h=ac50b837ec1cb428f60f8b84e8d5c4611287a3f5;hb=c04a2c8359536c96c5d7a65207e96c3c089a7812;hp=8e8060486925d6924b0588869a1ae860a696d59d;hpb=ed3fb601b5694a239054a4faf74e249d6ea4e199;p=supertux.git diff --git a/lib/special/sprite.cpp b/lib/special/sprite.cpp index 8e8060486..ac50b837e 100644 --- a/lib/special/sprite.cpp +++ b/lib/special/sprite.cpp @@ -131,9 +131,6 @@ if(i == actions.end()) return; } action = i->second; - -if((int)frame >= get_frames()) - frame = 0; } void @@ -173,7 +170,11 @@ void Sprite::update() { if(animation_loops == 0) + { + if(frame >= get_frames() || frame < 0) + frame = 0; return; + } float frame_inc = (action->fps/1000.0) * (SDL_GetTicks() - last_tick); last_tick = SDL_GetTicks(); @@ -185,9 +186,9 @@ else if(animation_reversed) { - float excedent = frame - 0; - if((int)excedent < 0 || excedent >= get_frames()) + if(frame < 0 || frame >= (float)get_frames()) { // last case can happen when not used reverse_animation() + float excedent = frame - 0; frame = get_frames() - 1; if(animation_loops > 0) { @@ -205,9 +206,9 @@ if(animation_reversed) } else { - float excedent = frame - (get_frames()+1); - if((int)excedent >= 0) + if(frame >= (float)get_frames()) { + float excedent = frame - get_frames(); frame = 0; if(animation_loops > 0) {