summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRicardo Wurmus <rekado@elephly.net>2023-11-06 10:53:08 +0100
committerRicardo Wurmus <rekado@elephly.net>2023-11-06 10:53:08 +0100
commite5acb707aaceb92982b81f7170add924cc41653f (patch)
tree0eee10fba0b089903e2a53be5d2627f56d5ba54d
parenta7e74f2307f79d3c952fb11450dcd2c534c08249 (diff)
Fix update-animated-sprite.
-rw-r--r--scenes/death.scm8
-rw-r--r--scenes/game.scm8
-rw-r--r--utils.scm8
3 files changed, 13 insertions, 11 deletions
diff --git a/scenes/death.scm b/scenes/death.scm
index 5351dba..67e24a7 100644
--- a/scenes/death.scm
+++ b/scenes/death.scm
@@ -152,13 +152,13 @@ quite short."))
(vec2 (+ (/ %width 2) 25)
(- (/ %height 2) 20))
#:dead? #true))
- (update-animated-sprite *player* 0)
+ (update-animated-sprite *player*)
(set! (walk-speed *player*) 0.3)
(set! *reaper* (reaper #:start-position
(vec2 (+ (/ %width 2) 110)
(- (/ %height 2) 20))))
- (update-animated-sprite *reaper* 0)
+ (update-animated-sprite *reaper*)
(set! (walk-speed *reaper*) 0.3)
(with-agenda
@@ -316,8 +316,8 @@ quite short."))
(define (update-scene dt)
(update-agenda dt)
- (update-animated-sprite *player* dt)
- (update-animated-sprite *reaper* dt)
+ (update-animated-sprite *player*)
+ (update-animated-sprite *reaper*)
;; Move the world
(unless pretend-walking?
diff --git a/scenes/game.scm b/scenes/game.scm
index 3fe2a45..442071e 100644
--- a/scenes/game.scm
+++ b/scenes/game.scm
@@ -94,7 +94,7 @@ map's positions layer."
))
(set! *player* (lorenzo #:start-position
(location "player")))
- (update-animated-sprite *player* 0)
+ (update-animated-sprite *player*)
(grid-add grid 'player
(+ (vec2-x (position *player*)) player-grid-x-offset)
(+ (vec2-y (position *player*)) player-grid-y-offset)
@@ -103,7 +103,7 @@ map's positions layer."
(set! *reaper* (reaper #:start-position
(location "reaper")))
- (update-animated-sprite *reaper* 0)
+ (update-animated-sprite *reaper*)
;; XXX: Chickadee parses the object layer incorrectly, so all
;; objects are flipped vertically. We use this to compute the
@@ -248,8 +248,8 @@ map's positions layer."
(define (update-scene dt)
(update-agenda dt)
- (update-animated-sprite *player* dt)
- (update-animated-sprite *reaper* dt))
+ (update-animated-sprite *player*)
+ (update-animated-sprite *reaper*))
(define scene
diff --git a/utils.scm b/utils.scm
index 5533cc0..df93b26 100644
--- a/utils.scm
+++ b/utils.scm
@@ -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)))