+else
+ {
+ float excedent = frame - action->surfaces.size();
+ if((int)excedent >= 0)
+ {
+ 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;
+ }
+ }
+}
+
+void
+Sprite::draw(DrawingContext& context, const Vector& pos, int layer,
+ Uint32 drawing_effect)
+{
+ update();
+
+ if((int)frame >= get_frames() || (int)frame < 0)
+ std::cerr << "Warning: frame out of range: " << (int)frame
+ << "/" << get_frames() << " at sprite: " << get_name()
+ << "/" << get_action_name() << std::endl;
+ else
+ context.draw_surface(action->surfaces[(int)frame],
+ pos - Vector(action->x_offset, action->y_offset), layer, drawing_effect);