From 0a50d6c79aa7893fa2c7ce0326e87e1f44410248 Mon Sep 17 00:00:00 2001 From: Ricardo Wurmus Date: Sun, 8 Jul 2018 10:15:53 +0200 Subject: Draw a top layer above the player. --- scenes/game.scm | 30 +++++++++++++++++------------- 1 file 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 () + (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 + #:name 'top-layer + #:position (vec2 0.0 0.0)) (make #:name 'stats #:player player #:position (vec2 10.0 (- %height 10.0)))))) @@ -212,6 +218,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)))))) @@ -246,19 +255,14 @@ (define-method (draw (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 ) 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) -- cgit v1.2.3