diff options
| -rw-r--r-- | animation.scm | 8 | ||||
| -rw-r--r-- | tests/animation-test.scm | 7 |
2 files changed, 8 insertions, 7 deletions
diff --git a/animation.scm b/animation.scm index c8f4497..e3e6e89 100644 --- a/animation.scm +++ b/animation.scm @@ -53,10 +53,10 @@ ;; Entities without #:anim-name are returned unchanged. (define (advance-animation entity anim) - (let* ((tick (+ 1 (entity-ref entity #:anim-tick 0))) - (duration (animation-duration anim)) - (frames (animation-frames anim)) - (frame (entity-ref entity #:anim-frame 0))) + (let ((tick (+ 1 (entity-ref entity #:anim-tick 0))) + (duration (animation-duration anim)) + (frames (animation-frames anim)) + (frame (entity-ref entity #:anim-frame 0))) (if (>= tick duration) (let ((new-frame-id (modulo (+ frame 1) (length frames)))) (entity-set-many entity diff --git a/tests/animation-test.scm b/tests/animation-test.scm index 9a71dec..87b18e7 100644 --- a/tests/animation-test.scm +++ b/tests/animation-test.scm @@ -20,7 +20,8 @@ (test-group "frame->duration" (test-equal "first frame, frames (0)" 100 (frame->duration '((0 100)) 0)) (test-equal "wraps around" 100 (frame->duration '((0 100) (1 200)) 2)) - (test-equal "frame 1 of (27 28)" 200 (frame->duration '((27 100) (28 200)) 1))) + (test-equal "frame 1 of (27 28)" 200 (frame->duration '((27 100) (28 200)) 1)) +) (test-group "set-animation" (let ((entity (list #:type 'player #:anim-name 'idle #:anim-frame 5 #:anim-tick 8))) @@ -57,10 +58,10 @@ (test-group "animated entity" (let* ((anims '((#:name walk #:frames (2 3) #:duration 4))) (entity (list #:type 'player #:anim-name 'walk #:anim-frame 0 #:anim-tick 0 #:animations anims)) - (stepped-entity (apply-animation entity #f 10))) + (stepped-entity (apply-animation #f entity 10))) (test-equal "Updated animated entity" 1 (entity-ref stepped-entity #:anim-tick))) (let* ((entity (list #:type 'static)) - (stepped-entity (apply-animation entity #f 10))) + (stepped-entity (apply-animation #f entity 10))) (test-equal "unchanged static entity" #f (entity-ref stepped-entity #:anim-tick))))) (test-end "animation") |
