-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdamageText.lua
38 lines (33 loc) · 927 Bytes
/
damageText.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
damageText = {
container = {}
}
function damageText.reset()
damageText.container = {}
end
-- t = {v=_, x=_, y=_}
function damageText.add(t)
if t.v == nil then t.v = 0 end
if t.x == nil then t.x = 0 end
if t.y == nil then t.y = 0 end
t.v = tostring(t.v)
t.timer = 1
table.insert(damageText.container, t)
end
function damageText.update(dt)
for k, v in pairs(damageText.container) do
v.timer = v.timer - dt*0.5
if v.timer < 0 then
damageText.container[k] = nil
end
end
end
function damageText.draw()
local font = fonts.stats
love.graphics.setFont(font)
for _, v in pairs(damageText.container) do
local t = ease.outCubic(1 - v.timer)
local y = v.y - t*8
love.graphics.setColor(1, 0, 0, 1 - t)
love.graphics.print(v.v, lume.round(v.x - font:getWidth(v.v)/2), lume.round(y - font:getHeight()/2))
end
end