aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/animation-test.scm23
1 files changed, 13 insertions, 10 deletions
diff --git a/tests/animation-test.scm b/tests/animation-test.scm
index 356f44c..00dd217 100644
--- a/tests/animation-test.scm
+++ b/tests/animation-test.scm
@@ -23,9 +23,12 @@
(test "frame 1 of (27 28)" 28 (frame->tile-id '((27 10) (28 10)) 1))))
(test-group "frame->duration"
- (test "first frame, frames (0)" 100 (frame->duration '((0 100)) 0))
- (test "wraps around" 100 (frame->duration '((0 100) (1 200)) 2))
- (test "frame 1 of (27 28)" 200 (frame->duration '((27 100) (28 200)) 1))
+ (test "first frame, frames (0)" 100 (frame->duration '((#:frames . ((0 100))))
+ 0))
+ (test "wraps around" 100 (frame->duration '((#:frames . ((0 100) (1 200))))
+ 0))
+ (test "frame 1 of (27 28)" 200 (frame->duration '((#:frames . ((27 100) (28 200))))
+ 1))
)
(test-group "set-animation"
@@ -40,33 +43,33 @@
(test-group "Single frames"
(let* ((anims (list (anim #:name 'walk #:frames '(2 3) #:duration 4)))
(e (entity #:type 'player #:anim-name 'walk #:anim-frame 0 #:anim-tick 0))
- (stepped (animate-entity e anims)))
+ (stepped (animate-entity e anims 1)))
(test "increments tick" 1 (entity-ref stepped #:anim-tick))
(test "sets tile-id on first tick" 2 (entity-ref stepped #:tile-id)))
(let* ((anims (list (anim #:name 'walk #:frames '(0 1) #:duration 2)))
(e (entity #:type 'player #:anim-name 'walk #:anim-frame 0 #:anim-tick 1))
- (advanced (animate-entity e anims)))
+ (advanced (animate-entity e anims 200)))
(test "advances frame when tick reaches duration" 1 (entity-ref advanced #:anim-frame))
(test "resets tick on frame advance" 0 (entity-ref advanced #:anim-tick))))
(test-group "Frames with duration"
(let* ((anims (list (anim #:name 'walk #:frames '((0 10) (1 20)) #:duration 4)))
(e (entity #:type 'player #:anim-name 'walk #:anim-frame 0 #:anim-tick 9))
- (stepped (animate-entity e anims)))
+ (stepped (animate-entity e anims 200)))
(test "ticks resets on frame switch" 0 (entity-ref stepped #:anim-tick))
(test "sets tile-id on 10th tick" 1 (entity-ref stepped #:tile-id))
(test "sets duration to frame duration" 20 (entity-ref stepped #:duration))))
(test-group "Empty"
(let* ((e (entity #:type 'player)))
- (test "unchanged entity without anim-name" e (animate-entity e '())))))
+ (test "unchanged entity without anim-name" e (animate-entity e '() 1)))))
(test-group "animation pipeline"
(test-group "animated entity"
(let* ((anims (list (anim #:name 'walk #:frames '(2 3) #:duration 4)))
(e (entity #:type 'player #:anim-name 'walk #:anim-frame 0 #:anim-tick 0 #:animations anims))
- (stepped-entity (apply-animation #f e 10)))
- (test "Updated animated entity" 1 (entity-ref stepped-entity #:anim-tick)))
+ (stepped-entity (apply-animation #f e 10)))
+ (test "Updated animated entity" 10 (entity-ref stepped-entity #:anim-tick)))
(let* ((e (entity #:type 'static))
- (stepped-entity (apply-animation #f e 10)))
+ (stepped-entity (apply-animation #f e 10)))
(test "unchanged static entity" #f (entity-ref stepped-entity #:anim-tick)))))
(test-end "animation")