diff options
author | Ricardo Wurmus <rekado@elephly.net> | 2018-07-08 10:15:53 +0200 |
---|---|---|
committer | Ricardo Wurmus <rekado@elephly.net> | 2018-07-27 17:15:43 +0200 |
commit | 0a50d6c79aa7893fa2c7ce0326e87e1f44410248 (patch) | |
tree | 86f72f3b80fa5c0603cce6e34a2111fe5c15950a | |
parent | 9bd5cf49e1ae917d966d85dd8b4c865b04ab46b3 (diff) |
Draw a top layer above the player.
-rw-r--r-- | scenes/game.scm | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/scenes/game.scm b/scenes/game.scm index 30d2d5c..cc110f9 100644 --- a/scenes/game.scm +++ b/scenes/game.scm @@ -118,6 +118,9 @@ (tile-map #:accessor tile-map #:init-form test-map) (collision-hitbox #:getter collision-hitbox #:init-form (make-rect 0.0 0.0 0.0 0.0))) +(define-class <top-layer> (<node-2d>) + (tile-map #:accessor tile-map #:init-form test-map)) + (define-asset game-font (load-tile-font "assets/fonts/bubblemad_8x8.png" 8 8 " !\"©_%❤'()*+,-./0123456789:←<=>?@abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")) @@ -138,6 +141,9 @@ #:region (make-rect 0.0 0.0 0.0 0.0) #:position (vec2 0 0) #:color (transparency 0.2)) + (make <top-layer> + #:name 'top-layer + #:position (vec2 0.0 0.0)) (make <stats> #:name 'stats #:player player #:position (vec2 10.0 (- %height 10.0)))))) @@ -213,6 +219,9 @@ ;; Keep the player in the centre (move-to game (- 0 (vec2-x pos)) + (- 0 (vec2-y pos))) + (move-to (child-ref game 'top-layer) + (- 0 (vec2-x pos)) (- 0 (vec2-y pos)))))) (define-method (draw (stats <stats>) alpha) @@ -246,19 +255,14 @@ (define-method (draw (game <game>) alpha) (draw-tile-map (asset-ref (tile-map game)) #:position (position game) - #:layers (list 0 1 2 3 4) - ;; (list "tiles" - ;; "decoration" - ;; "fence" - ;; "collision" - ;; "objects") - ) - (next-method) - ;; Top-most layer - (draw-tile-map (asset-ref (tile-map game)) - #:position (position game) - #:layers (list 5)) - ) + #:layers (list 0 1 2 3))) + +(define-method (draw (top-layer <top-layer>) alpha) + (draw-tile-map (asset-ref (tile-map top-layer)) + #:position (position top-layer) + ;; NOTE: this is the 5th tile layer; object layers + ;; are ignored. + #:layers (list 4))) (define (decrease-lifetime) |