diff options
Diffstat (limited to 'texts.lua')
-rw-r--r-- | texts.lua | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/texts.lua b/texts.lua new file mode 100644 index 0000000..9f9ff97 --- /dev/null +++ b/texts.lua @@ -0,0 +1,35 @@ +local util = require 'util' + +local texts = {} + +local function add(text,x,y) + 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, +} |