-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhud.lua
60 lines (51 loc) · 1.44 KB
/
hud.lua
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
-- Hud
-- Represents the heads-up-display content
Hud = {}
function Hud:new(o)
o = o or {}
setmetatable(o, self)
self.__index = self
return o
end
function Hud:draw(x, y, energy, knowledge, kmax, brain)
love.graphics.setColor(0,0,0)
love.graphics.rectangle("line", x,y, 800, 40)
love.graphics.setColor(128, 128, 128)
love.graphics.rectangle("fill", x,y, 800, 40)
love.graphics.setColor(255, 255, 255)
energy = math.floor(energy + 0.5)
local estr = energy
if estr < 0 then
estr = "000"
elseif estr < 10 then
estr = "00" .. energy
elseif estr < 100 then
estr = "0" .. energy
end
kmaxstr = kmax
if kmaxstr < 10 then
kmaxstr = "00" .. kmax
elseif kmaxstr < 100 then
kmaxstr = "0" .. kmax
end
kstr = knowledge
if kstr < 10 then
kstr = "00" .. knowledge
elseif kstr < 100 then
kstr = "0" .. knowledge
end
love.graphics.draw(battery_img, x+10, y+15)
love.graphics.print("Energy: " .. estr, x+40, y+15)
love.graphics.draw(book_img, x+130, y+6)
love.graphics.print("Knowledge: " .. kstr .. "/" .. kmaxstr, x+170, y+15)
if energy <= 0 then
love.graphics.print("You LOSE!", x+800-40-35, y+15)
elseif brain and knowledge == kmax then
love.graphics.print("You WIN!", x+800-40-35, y+15)
elseif brain then
love.graphics.print("Found the BRAIN!", x+800-100-35, y+15)
else
love.graphics.print("Find: ", x+800-40-35, y+15)
love.graphics.draw(brain_img, 800-40, y+6)
end
end