-
Notifications
You must be signed in to change notification settings - Fork 1
/
hud.fnl
84 lines (74 loc) · 3.71 KB
/
hud.fnl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
(var crashed-image nil)
(var victory-image nil)
{:load (fn []
(set crashed-image
(love.graphics.newImage "assets/crashed.png"))
(set victory-image
(love.graphics.newImage "assets/victory.png")))
:update (fn [level])
:draw (fn [level]
(if
(= level.state :in-flight)
(do
(love.graphics.setColor 255 255 0 255)
(love.graphics.print (string.format "IN-FLIGHT : %3.2fs" level.duration) 10 10))
(= level.state :awaiting-launch)
(do
(love.graphics.setColor 0 255 0 255)
(love.graphics.print "AWAITING LAUNCH : PRESS SPACE TO LAUNCH" 10 10)
(love.graphics.print "CLICK AND DRAG PLANETS TO ADJUST POSITION" 10 25))
(= level.state :crashed)
(do
(love.graphics.setColor 255 0 0 255)
(love.graphics.print (string.format "Time: %3.2fs"
level.duration)
10 10)
(love.graphics.draw crashed-image
(/ (- (love.graphics.getWidth)
(: crashed-image :getWidth))
2)
(/ (- (love.graphics.getHeight)
(: crashed-image :getHeight))
2)))
(do
(love.graphics.setColor 255 255 255 255)
(love.graphics.draw victory-image
(/ (- (love.graphics.getWidth)
(: victory-image :getWidth))
2)
(/ (- (love.graphics.getHeight)
(: victory-image :getHeight))
2))
(when (= level.resource-score 0)
(love.graphics.print "Try and pick some resources next time, I mean, that's your mission."
118 400))))
(love.graphics.setColor 255 255 255 255)
(love.graphics.printf (string.format "SURVIVAL SCORE: %08d"
level.survival-score-offered)
(- (love.graphics.getWidth) 250)
10
230
"right")
(love.graphics.printf (string.format "RESOURCE SCORE: %08d"
level.resource-score)
(- (love.graphics.getWidth) 250)
25
230 "right")
(love.graphics.printf (string.format "SCORE: %08d"
(+ level.resource-score
level.survival-score-offered))
(- (love.graphics.getWidth) 250) 40
230 "right")
(love.graphics.setColor 255 255 0 255)
(if
(= level.state :in-flight)
(love.graphics.print (string.format
"SPACE : RESET S : SPEED UP (%dx)"
level.speed-up)
10 (- (love.graphics.getHeight) 30))
(= level.state :complete)
(love.graphics.print "SPACE : NEXT MISSION R : RETRY"
10 (- (love.graphics.getHeight) 30))
(= level.state :crashed)
(love.graphics.print "SPACE : RESTART"
10 (- (love.graphics.getHeight) 30))))}