From 0cb68be20bc265a2635725cace43a634fdb539da Mon Sep 17 00:00:00 2001 From: "Jakob L. Kreuze" Date: Wed, 24 Oct 2018 16:50:38 -0400 Subject: Initial HUD implementation --- world.fnl | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'world.fnl') diff --git a/world.fnl b/world.fnl index bde756c..f4a9cce 100644 --- a/world.fnl +++ b/world.fnl @@ -90,6 +90,17 @@ (when (~= :empty (. tile :type)) (draw-tile tile screen-x screen-y)))))))) +(fn draw-hud [world screen-width screen-height] + (let [cur-health (. world :player :cur-health) + max-health (. world :player :max-health) + font-height (: (love.graphics.getFont) :getHeight) + surfaces-slimed (. world :surfaces-slimed) + surfaces-total (. world :surfaces-total) + health-msg (string.format "h: %d/%d" cur-health max-health) + slime-msg (string.format "s: %d/%d" surfaces-slimed surfaces-total)] + (love.graphics.print health-msg 0 (- screen-height (* 2 font-height))) + (love.graphics.print slime-msg 0 (- screen-height font-height)))) + (fn draw-world [world camera-x camera-y screen-width screen-height] (love.graphics.clear 0.1 0.1 0.1) (draw-map world camera-x camera-y screen-width screen-height) @@ -99,12 +110,7 @@ x (- player-x camera-x) y (- player-y camera-y)] (: player :draw x y)) - ;; TODO: Refactor this into multiple functions - (love.graphics.print (string.format "%d/%d" (. world :surfaces-slimed) - (. world :surfaces-total)) - 0 0)) - - + (draw-hud world screen-width screen-height)) ;; Returns whether or not `tile' exists in `checked'. (fn tile-checked [tile checked] -- cgit v1.3