summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2018-04-29 20:56:05 -0400
committerDavid Thompson <dthompson2@worcester.edu>2018-04-29 20:56:05 -0400
commitaa7897142cea94d5a1bcf66e48f0465a521c73f8 (patch)
tree31e64679ee7bf60b858f09833206be7a88045cde
parentc9582b3f68d11d1e036a8f9bdcfd4eb3e8a4239f (diff)
render: tiled: Add tile-map-layer-ref.
* chickadee/render/tiled.scm (tile-map-layer-ref): New procedure.
-rw-r--r--chickadee/render/tiled.scm17
1 files changed, 17 insertions, 0 deletions
diff --git a/chickadee/render/tiled.scm b/chickadee/render/tiled.scm
index 23c68d9..802a9a2 100644
--- a/chickadee/render/tiled.scm
+++ b/chickadee/render/tiled.scm
@@ -46,6 +46,7 @@
tile-map-layers
tile-map-properties
tile-map-rect
+ tile-map-layer-ref
animation-frame?
animation-frame-tile
@@ -174,6 +175,22 @@
(shape map-object-shape)
(properties map-object-properties))
+(define (tile-map-layer-ref tile-map name)
+ "Return the layer named NAME."
+ (define (layer-name layer)
+ (if (tile-layer? layer)
+ (tile-layer-name layer)
+ (object-layer-name layer)))
+ (let ((layers (tile-map-layers tile-map)))
+ (let loop ((i 0))
+ (cond
+ ((= i (vector-length layers))
+ #f)
+ ((string=? name (layer-name (vector-ref layers i)))
+ (vector-ref layers i))
+ (else
+ (loop (+ i 1)))))))
+
(define (load-tile-map file-name)
"Load the Tiled TMX formatted map in FILE-NAME."
(define map-directory