summaryrefslogtreecommitdiff
path: root/texts.lua
blob: 379f55fdbe1c05bf4c651b619bf4370c1c0ddaaf (plain)
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
local util = require 'util'

local texts = {}

local function add(text,x,y)
	print('(texts): '..text)
	table.insert(texts,{
		x=x,y=y,life=3,text=text
	})
end

local function draw()
	for i=#texts,1,-1 do
		local t = texts[i]
		util.write_at(t.text,t.x,t.y)
	end
end

local SPEED = 0.1

local function update(dt)
	for i=#texts,1,-1 do
		local t = texts[i]
		t.y = t.y - SPEED * dt
		t.life = t.life - dt
		if t.life < 0 then
			table.remove(texts, i)
		end
	end
end

return {
	add=add,
	update=update,
	draw=draw,
}