diff options
author | David Thompson <dthompson2@worcester.edu> | 2018-04-29 20:56:05 -0400 |
---|---|---|
committer | David Thompson <dthompson2@worcester.edu> | 2018-04-29 20:56:05 -0400 |
commit | aa7897142cea94d5a1bcf66e48f0465a521c73f8 (patch) | |
tree | 31e64679ee7bf60b858f09833206be7a88045cde | |
parent | c9582b3f68d11d1e036a8f9bdcfd4eb3e8a4239f (diff) |
render: tiled: Add tile-map-layer-ref.
* chickadee/render/tiled.scm (tile-map-layer-ref): New procedure.
-rw-r--r-- | chickadee/render/tiled.scm | 17 |
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 |