Skip to content

Commit

Permalink
Fix looping behaviour for pingpong animation (#254)
Browse files Browse the repository at this point in the history
* Fix looping behaviour for pingpong animation

* Fix pingpong animatino for non looping

* Simplify bounce back code
  • Loading branch information
bullno1 authored Dec 17, 2024
1 parent fe7e7a3 commit 87b203a
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions include/cute_sprite.h
Original file line number Diff line number Diff line change
Expand Up @@ -534,20 +534,16 @@ CF_INLINE void cf_sprite_update(CF_Sprite* sprite)
if (sprite->frame_index < 0) {
if (sprite->loop) {
sprite->loop_count++;
sprite->frame_index = frame_count - 1;
} else {
sprite->frame_index++;
} else {
sprite->frame_index = 0;
}
}
} else {
sprite->frame_index++;
if (sprite->frame_index == frame_count) {
if (sprite->loop) {
sprite->loop_count++;
sprite->frame_index = 0;
} else {
sprite->frame_index--;
}
sprite->loop_count++;
sprite->frame_index--;
}
}
}
Expand Down

0 comments on commit 87b203a

Please sign in to comment.