diff options
Diffstat (limited to 'utils.scm')
-rw-r--r-- | utils.scm | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -118,12 +118,14 @@ given MAX-WIDTH. Return a list of lines." (vec2+ offset (position sprite)) #:tint (tint sprite))) -(define (update-animated-sprite sprite dt) +(define (update-animated-sprite sprite) (let* ((anim (assq-ref (animations sprite) (current-animation sprite))) (frame-duration (frame-duration sprite)) (anim-duration (* frame-duration (vector-length anim))) - (time (modulo (- (agenda-time) (start-time sprite)) anim-duration)) - (frame (vector-ref anim (floor (/ time frame-duration)))) + (time (floor-remainder (- (agenda-time) (start-time sprite)) + anim-duration)) + (frame (vector-ref anim (inexact->exact + (floor (/ time frame-duration))))) (texture-region (texture-atlas-ref (asset-ref (atlas sprite)) frame))) (set! (texture sprite) texture-region))) |