+ 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)
+ {
+ animation_loops--;
+ if(animation_loops == 0 && !next_action.empty())
+ {
+ set_action(next_action);
+ start_animation(-1);
+ }
+ }
+
+ if(fabsf(excedent) < get_frames())
+ frame += excedent;
+ }
+ }
+else
+ {
+ if(frame >= (float)get_frames())
+ {
+ float excedent = frame - get_frames();
+ frame = 0;
+ if(animation_loops > 0)
+ {
+ animation_loops--;
+ if(animation_loops == 0 && !next_action.empty())
+ {
+ set_action(next_action);
+ start_animation(-1);
+ }
+ }
+
+ if(excedent < get_frames())
+ frame += excedent;
+ }