diff options
author | David Thompson <dthompson2@worcester.edu> | 2018-08-30 08:38:55 -0400 |
---|---|---|
committer | David Thompson <dthompson2@worcester.edu> | 2018-08-30 08:38:55 -0400 |
commit | 0d3b18450c70b0350f1e4d6538f2a9b86a9ea533 (patch) | |
tree | 8ac476f36c607d882dae90c6a8480897d356fb74 | |
parent | db5cd16428f88ceb7d2906486de6c18753f95ec6 (diff) |
node-2d: Add tile map node.
* starling/node-2d.scm (<tile-map>): New class.
(tile-map, layers): New methods.
-rw-r--r-- | starling/node-2d.scm | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/starling/node-2d.scm b/starling/node-2d.scm index 8e3cad6..19ca545 100644 --- a/starling/node-2d.scm +++ b/starling/node-2d.scm @@ -33,6 +33,7 @@ #:use-module (chickadee render shapes) #:use-module (chickadee render sprite) #:use-module (chickadee render texture) + #:use-module (chickadee render tiled) #:use-module (chickadee render viewport) #:use-module (chickadee scripting) #:use-module (ice-9 match) @@ -89,7 +90,11 @@ <label> font - text)) + text + + <tile-map> + tile-map + layers)) ;;; @@ -475,3 +480,20 @@ (define-method (render (label <label>) alpha) (draw-text* (asset-ref (font label)) (text label) (world-matrix label))) + + +;;; +;;; Tiled Map +;;; + +(define-class <tile-map> (<node-2d>) + (tile-map #:accessor tile-map #:init-keyword #:map) + (layers #:accessor layers #:init-keyword #:layers #:init-form #f)) + +(define-method (initialize (node <tile-map>) initargs) + (next-method)) + +(define-method (render (node <tile-map>) alpha) + (let ((m (asset-ref (tile-map node)))) + (draw-tile-map* m (world-matrix node) (tile-map-rect m) + #:layers (layers node)))) |