summaryrefslogtreecommitdiff
path: root/chickadee/graphics/tiled.scm
diff options
context:
space:
mode:
Diffstat (limited to 'chickadee/graphics/tiled.scm')
-rw-r--r--chickadee/graphics/tiled.scm37
1 files changed, 16 insertions, 21 deletions
diff --git a/chickadee/graphics/tiled.scm b/chickadee/graphics/tiled.scm
index 2d2e88f..6500a17 100644
--- a/chickadee/graphics/tiled.scm
+++ b/chickadee/graphics/tiled.scm
@@ -29,6 +29,7 @@
#:use-module (chickadee graphics sprite)
#:use-module (chickadee graphics texture)
#:use-module (chickadee graphics viewport)
+ #:use-module (chickadee utils)
#:use-module (ice-9 match)
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-9)
@@ -253,13 +254,11 @@
(let ((tile (parse-tile node rows columns atlas batch)))
(hash-set! table (tile-id tile) tile)))
nodes)
- (let loop ((i 0))
- (when (< i size)
- (let ((tile
- (or (hash-ref table i)
- (%make-tile i (texture-atlas-ref atlas i) batch #f '()))))
- (vector-set! tiles i tile))
- (loop (+ i 1))))
+ (for-range ((i size))
+ (let ((tile
+ (or (hash-ref table i)
+ (%make-tile i (texture-atlas-ref atlas i) batch #f '()))))
+ (vector-set! tiles i tile)))
tiles))
(define (first-gid node)
(attr node 'firstgid string->number))
@@ -418,20 +417,16 @@
(define (draw-tile-layer layer matrix x1 y1 x2 y2)
(let ((width (tile-layer-width layer))
(height (tile-layer-height layer)))
- (let y-loop ((y y1))
- (when (< y y2)
- (let x-loop ((x x1))
- (when (< x x2)
- (let ((tile (vector-ref (tile-layer-tiles layer)
- (+ (* y width) x))))
- (when tile
- (let ((tref (map-tile-ref tile)))
- (sprite-batch-add* (tile-batch tref)
- (map-tile-rect tile)
- matrix
- #:texture-region (tile-texture tref)))))
- (x-loop (+ x 1))))
- (y-loop (+ y 1))))))
+ (for-range ((x x2 x1)
+ (y y2 y1))
+ (let ((tile (vector-ref (tile-layer-tiles layer)
+ (+ (* y width) x))))
+ (when tile
+ (let ((tref (map-tile-ref tile)))
+ (sprite-batch-add* (tile-batch tref)
+ (map-tile-rect tile)
+ matrix
+ #:texture-region (tile-texture tref))))))))
(define* (draw-tile-map* tile-map matrix region #:key layers)
;; Calculate the tiles that are visible so we don't waste time