}
bool
-Sprite::check_animation()
+Sprite::animation_done()
{
return animation_loops == 0;
}
void
Sprite::update()
{
- if(animation_loops == 0)
+ if(animation_done())
return;
Uint32 ticks = SDL_GetTicks();
frame += frame_inc;
if(frame >= get_frames()) {
- frame = fmodf(frame+get_frames(), get_frames());
-
+ frame = fmodf(frame, get_frames());
+
animation_loops--;
- if(animation_loops == 0)
- frame = 0;
+ if(animation_done())
+ frame = get_frames()-1;
}
}