Use state more, start on menus
This commit is contained in:
parent
e63a0039b6
commit
fd96d53a34
7 changed files with 315 additions and 217 deletions
75
overlay.fnl
75
overlay.fnl
|
@ -53,10 +53,81 @@
|
|||
(- x dx) (+ y by dy)))
|
||||
(set dx (+ dx bb))))
|
||||
|
||||
(fn overlay [dx dy]
|
||||
; This draws barriers around the screen
|
||||
; Eventually to be improved into a helmet
|
||||
(fn helmet-hud []
|
||||
(love.graphics.setColor 0 1 0 0.25)
|
||||
(love.graphics.line 0 0
|
||||
(+ (/ screen-width 6) 0) 35
|
||||
(+ (/ screen-width 3) 0) 30
|
||||
(- screen-width (/ screen-width 3)) 30
|
||||
(- screen-width (/ screen-width 6)) 35
|
||||
screen-width 0)
|
||||
; (love.graphics.polygon "fill" (- screen-width 20) 0
|
||||
; screen-width 0
|
||||
; screen-width (- screen-height 20)
|
||||
; (- screen-width 20) (- screen-height 20))
|
||||
; (love.graphics.polygon "fill" 0 0
|
||||
; 20 0
|
||||
; 20 screen-height
|
||||
; 0 screen-height)
|
||||
; (love.graphics.polygon "fill" 0 (- screen-height 50)
|
||||
; (/ screen-width 6) (- screen-height 35)
|
||||
; (/ screen-width 3) (- screen-height 30)
|
||||
; 0 screen-height)
|
||||
; (love.graphics.polygon "fill" screen-width (- screen-height 50)
|
||||
; (- screen-width (/ screen-width 6)) (- screen-height 35)
|
||||
; (- screen-width (/ screen-width 3)) (- screen-height 30)
|
||||
; screen-width screen-height)
|
||||
)
|
||||
|
||||
; This draws a compass bar at the top of the HUD
|
||||
(var hc-bar-east ["-" "-" "|" "N" "|"
|
||||
"-" "-" "|" "NE" "|"
|
||||
"-" "-" "|" "E" "|"
|
||||
"-" "-" "|" "SE" "|"
|
||||
"-" "|" "S" "|" "-" ])
|
||||
(var hc-bar-west ["-" "-" "|" "N" "|"
|
||||
"-" "-" "|" "NW" "|"
|
||||
"-" "-" "|" "W" "|"
|
||||
"-" "-" "|" "SW" "|"
|
||||
"-" "|" "S" "|" "-" ])
|
||||
(var hc-bar-limit 6)
|
||||
(fn circular-compass [l c n]
|
||||
(if (< (+ c n) 1) (length l)
|
||||
(> (+ c n) (length l)) 1
|
||||
(+ c n)))
|
||||
(fn compass-bar []
|
||||
(love.graphics.setColor 0 1 0 0.25)
|
||||
(var (hc-output hc-padding) (values "" " "))
|
||||
(var hc-idx (math.floor (+ 10 (* 10 (player.getDirX)))))
|
||||
(var hc-idx-mod 1)
|
||||
(for [i 1 (+ 1 hc-bar-limit)]
|
||||
(if (> (player.getDirY) 0)
|
||||
(do
|
||||
(set hc-idx-mod 1)
|
||||
(set hc-idx (circular-compass hc-bar-east hc-idx hc-idx-mod))
|
||||
(set hc-output (.. hc-output (. hc-bar-east hc-idx) hc-padding)))
|
||||
(do
|
||||
(set hc-idx-mod 1)
|
||||
(set hc-idx (circular-compass hc-bar-west hc-idx hc-idx-mod))
|
||||
(set hc-output (.. (. hc-bar-west hc-idx) hc-padding hc-output)))))
|
||||
hc-output)
|
||||
|
||||
(fn hud-compass []
|
||||
(var old-font (love.graphics.getFont))
|
||||
(love.graphics.setNewFont 20)
|
||||
(love.graphics.setColor 0.5 1 1 0.5)
|
||||
(var compass-bar-output (compass-bar))
|
||||
(love.graphics.printf compass-bar-output 0 50 screen-width :center)
|
||||
(love.graphics.setFont old-font))
|
||||
|
||||
(fn overlay [dx dy pos-x]
|
||||
(love.graphics.translate dx (- dy))
|
||||
(oxygen-ui (+ (/ screen-width 2) 100) (- screen-height 100))
|
||||
(power-ui (- (/ screen-width 2) 100) (- screen-height 100))
|
||||
; (power-ui (- (/ screen-width 2) 100) (- screen-height 100))
|
||||
(helmet-hud)
|
||||
(hud-compass)
|
||||
(love.graphics.setColor 1 1 1)
|
||||
)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue