summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2017-10-17 21:41:40 -0400
committerDavid Thompson <dthompson2@worcester.edu>2017-10-17 21:43:34 -0400
commit31b6f11b45d810a2e38e37f2f26ccd979166f356 (patch)
treeb6584174de099c8f1e4d55c96393af525f17dff8
parentc7d382fd2ddec2406d7672dd9b082b0e27d7df3c (diff)
render: texture: Use texture regions in texture atlas.
* chickadee/render/texture.scm (list->texture-atlas): Create texture regions. Switch from rects to 4-tuples. (texture-atlas, texture-atlas-ref): Update docstring. (split-texture): Create texture regions.
-rw-r--r--chickadee/render/texture.scm11
1 files changed, 6 insertions, 5 deletions
diff --git a/chickadee/render/texture.scm b/chickadee/render/texture.scm
index 2b4755e..9a1421a 100644
--- a/chickadee/render/texture.scm
+++ b/chickadee/render/texture.scm
@@ -274,17 +274,18 @@ coordinate rects denoting the various tiles within."
(rects rects))
(match rects
(() (%make-texture-atlas texture v))
- ((r . rest)
- (vector-set! v i r)
+ (((x y width height) . rest)
+ (vector-set! v i (make-texture-region texture x y width height))
(loop (1+ i) rest))))))
(define (texture-atlas texture . rects)
"Return a new atlas for TEXTURE containing RECTS, a series of
-texture coordinate rect arguments denoting the various tiles within."
+4-tuples in the form (x y width height) describing the various tiles
+within."
(list->texture-atlas texture rects))
(define (texture-atlas-ref atlas index)
- "Return the texture coordinate rect associated with INDEX in
+ "Return the texture region associated with INDEX in
ATLAS."
(vector-ref (texture-atlas-vector atlas) index))
@@ -308,7 +309,7 @@ terrain."
(define (make-tile tx ty)
(let* ((x (+ (* tx (+ tile-width spacing)) margin))
(y (+ (* ty (+ tile-height spacing)) margin)))
- (make-rect (/ x w) (/ y h) sw th)))
+ (make-texture-region texture x y tile-width tile-height)))
(let y-loop ((y 0))
(when (< y rows)
(let x-loop ((x 0))