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
|
local ui = {}
local translator = require "i18n.translator"
function ui.ammoBar()
local height = 30
local y = love.graphics.getHeight() - height
local x = 10
local gap = 20
local hearts = G.player.hearts
for i, v in pairs(hearts) do
local position = { x = x+gap*(i-1), y = y }
local heartR = config.heartSize
-- if a heart is charging
-- draw circle behind it to indicate the progress
local chargingStarted = G.player.chargingStarted
local chargingTime = G.time - (chargingStarted or 0)
if chargingStarted and i==G.player.nextBullet then
local arc = math.pi * 2 * (chargingTime or 0)
love.graphics.setColor(1,0,0,0.6)
love.graphics.arc("fill", position.x+heartR/2, position.y+heartR/2,
config.heartSize, 0, arc)
utils.resetGraphics()
end
if i == G.player.nextBullet then
heartR = heartR * 1.2
utils.resetGraphics()
end
-- draw heart
sprite.drawSquare(v, position, heartR)
end
end
function ui.roomClearedCounter()
love.graphics.print(translator.T("roomCleared") .. G.roomCleared, 0, 0)
end
function ui.roomName()
local text = G.currentRoom.name
local screenWidth = love.graphics.getWidth()
local font = love.graphics.getFont()
local textWidth = font:getWidth(text)
love.graphics.print(text, screenWidth - textWidth, 0)
end
function ui.speakerText()
speaker.print()
end
return ui
|