}
action = newaction;
- if(frame >= get_frames()) {
- frame = fmodf(frame, get_frames());
-
- if (animation_loops > 0) animation_loops--;
+ while(frame >= get_frames()) {
+ frame -= get_frames();
+ animation_loops--;
if(animation_done())
frame = get_frames()-1;
+ break;
}
}
void
Sprite::update()
{
- if(animation_done())
+ if(animation_done()) {
+ frame = get_frames()-1;
return;
+ }
float frame_inc = action->fps * (game_time - last_ticks);
last_ticks = game_time;
frame += frame_inc;
- if(frame >= get_frames()) {
- frame = fmodf(frame, get_frames());
-
+ while(frame >= get_frames()) {
+ frame -= get_frames();
animation_loops--;
if(animation_done())
frame = get_frames()-1;
+ break;
}
}
update();
if((int)frame >= get_frames() || (int)frame < 0)
- log_warning << "frame out of range: " << (int)frame << "/" << get_frames() << " at " << get_name() << "/" << get_action() << std::endl;
+ log_warning << "frame out of range: " << frame << "/" << get_frames() << " at " << get_name() << "/" << get_action() << std::endl;
else {
context.set_drawing_effect(effect);
context.draw_surface(action->surfaces[(int)frame],
{
if((int)frame >= get_frames() || (int)frame < 0)
{
- log_warning << "frame out of range: " << (int)frame << "/" << get_frames() << " at " << get_name() << "/" << get_action() << std::endl;
+ log_warning << "frame out of range: " << frame << "/" << get_frames() << " at " << get_name() << "/" << get_action() << std::endl;
return 0;
}
else
{
if((int)frame >= get_frames() || (int)frame < 0)
{
- log_warning << "frame out of range: " << (int)frame << "/" << get_frames() << " at " << get_name() << "/" << get_action() << std::endl;
+ log_warning << "frame out of range: " << frame << "/" << get_frames() << " at " << get_name() << "/" << get_action() << std::endl;
return 0;
}
else