65 lines
2.5 KiB
Text
65 lines
2.5 KiB
Text
|
; Draw the overlay
|
||
|
; Relies on information about the player and the display
|
||
|
(local player (require :state))
|
||
|
(var screen-width 1280)
|
||
|
(var screen-height 720)
|
||
|
|
||
|
; This draws the oxygen ui
|
||
|
; Sequential blocks, up to 10; each block 10%
|
||
|
(fn oxygen-ui [x y]
|
||
|
(local (bx by bb o) (values 10 10 15 (player.getO)))
|
||
|
(local bn (math.floor (/ o 10)))
|
||
|
(var (dx dy) (values 0 50))
|
||
|
(local bp (* 5 (% o 10)))
|
||
|
(love.graphics.setColor 0 1 0 0.25)
|
||
|
(for [i 1 10]
|
||
|
(love.graphics.polygon "line" (+ x dx 1) (+ y by 1)
|
||
|
(+ x dx bx 1) (+ y by 1)
|
||
|
(+ x dx bx 1) (+ y by dy 1)
|
||
|
(+ x dx 1) (+ y by dy 1))
|
||
|
(if (<= i bn)
|
||
|
(love.graphics.polygon "fill" (+ x dx) (+ y by)
|
||
|
(+ x dx bx) (+ y by)
|
||
|
(+ x dx bx) (+ y by dy)
|
||
|
(+ x dx) (+ y by dy)))
|
||
|
(if (= i (+ bn 1))
|
||
|
(love.graphics.polygon "fill" (+ x dx) (+ y (- (+ dy by) bp))
|
||
|
(+ x dx bx) (+ y (- (+ dy by) bp))
|
||
|
(+ x dx bx) (+ y by dy)
|
||
|
(+ x dx) (+ y by dy)))
|
||
|
(set dx (+ dx bb))))
|
||
|
|
||
|
; This draws the power ui
|
||
|
; Inverse-sequential blocks, up to 10; each block 10%
|
||
|
(fn power-ui [x y]
|
||
|
(local (bx by bb p) (values 10 10 15 (player.getP)))
|
||
|
(local bn (math.floor (/ p 10)))
|
||
|
(var (dx dy) (values 0 50))
|
||
|
(local bp (* 5 (% p 10)))
|
||
|
(love.graphics.setColor 1 1 0 0.25)
|
||
|
(for [i 1 10]
|
||
|
(love.graphics.polygon "line" (- x dx 1) (+ y by 1)
|
||
|
(- x dx bx 1) (+ y by 1)
|
||
|
(- x dx bx 1) (+ y by dy 1)
|
||
|
(- x dx 1) (+ y by dy 1))
|
||
|
(if (<= i bn)
|
||
|
(love.graphics.polygon "fill" (- x dx) (+ y by)
|
||
|
(- x dx bx) (+ y by)
|
||
|
(- x dx bx) (+ y by dy)
|
||
|
(- x dx) (+ y by dy)))
|
||
|
(if (= i (+ bn 1))
|
||
|
(love.graphics.polygon "fill" (- x dx) (+ y (- (+ dy by) bp))
|
||
|
(- x dx bx) (+ y (- (+ dy by) bp))
|
||
|
(- x dx bx) (+ y by dy)
|
||
|
(- x dx) (+ y by dy)))
|
||
|
(set dx (+ dx bb))))
|
||
|
|
||
|
(fn overlay [dx dy]
|
||
|
(love.graphics.translate dx (- dy))
|
||
|
(oxygen-ui (+ (/ screen-width 2) 100) (- screen-height 100))
|
||
|
(power-ui (- (/ screen-width 2) 100) (- screen-height 100))
|
||
|
(love.graphics.setColor 1 1 1)
|
||
|
)
|
||
|
|
||
|
{: overlay}
|