diff options
-rw-r--r-- | chickadee/render/tiled.scm | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/chickadee/render/tiled.scm b/chickadee/render/tiled.scm index 8e8b8f4..1a4c200 100644 --- a/chickadee/render/tiled.scm +++ b/chickadee/render/tiled.scm @@ -280,8 +280,17 @@ (if (attr node 'source) (parse-external-tileset node) (parse-internal-tileset node (first-gid node)))) - (define (tile-gid->map-tile gid tilesets x y tile-width tile-height) - (let* ((tileset (find (lambda (t) + (define (tile-gid->map-tile raw-gid tilesets x y tile-width tile-height) + ;; The top 3 bits of the tile gid are flags for various types of + ;; flipping. + ;; + ;; TODO: Respect the flipping settings. + (let* ((flipped-horizontally? (> (logand raw-gid #x80000000) 0)) + (flipped-vertically? (> (logand raw-gid #x40000000) 0)) + (flipped-diagonally? (> (logand raw-gid #x20000000) 0)) + ;; Remove the upper 3 bits to get the true tile id. + (gid (logand raw-gid #x1FFFFFFF)) + (tileset (find (lambda (t) (and (>= gid (tileset-first-gid t)) (< gid (+ (tileset-first-gid t) (tileset-size t))))) |