X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=lib%2Fspecial%2Fsprite.cpp;h=f676c085a113e9232225c16fa61900207cae3921;hb=add0f0d960ae9c5e539f401efdaa9da4f157555e;hp=d9134885e8ac8471518c1397d14349d2a9184a94;hpb=bb1bc5a5db8e4e81646b3a006e8f8b5931cf1d2b;p=supertux.git diff --git a/lib/special/sprite.cpp b/lib/special/sprite.cpp index d9134885e..f676c085a 100644 --- a/lib/special/sprite.cpp +++ b/lib/special/sprite.cpp @@ -150,20 +150,20 @@ else last_tick = SDL_GetTicks(); -if(!animation_reversed) +if(animation_reversed) { - if((unsigned int)frame >= action->surfaces.size()) + if((unsigned int)frame < 0) { - frame = 0; + frame = get_frames()-1; if(animation_loops > 0) animation_loops--; } } else { - if((unsigned int)frame < 0) + if((unsigned int)frame >= action->surfaces.size()) { - frame = get_frames()-1; + frame = 0; if(animation_loops > 0) animation_loops--; } @@ -176,8 +176,8 @@ Sprite::draw(DrawingContext& context, const Vector& pos, int layer, { update(); - if((int)frame >= get_frames()) - std::cerr << "Warning: frame higher than total frames!\n"; + if((int)frame >= get_frames() || (int)frame < 0) + std::cerr << "Warning: frame higher than total frames or lower than 0!\n"; else context.draw_surface(action->surfaces[(int)frame], pos - Vector(action->x_hotspot, action->y_hotspot), layer, drawing_effect);