summaryrefslogtreecommitdiff
path: root/texts.lua
diff options
context:
space:
mode:
authorubq323 <ubq323@ubq323.website>2024-01-05 03:50:58 +0000
committerubq323 <ubq323@ubq323.website>2024-01-05 03:50:58 +0000
commitbf3fbc24a50c2f4d732fd559f1a81523eeb066c6 (patch)
treee678ca446e685088c5f346c0e269c7dbaf22399e /texts.lua
parent727b0648d8101ec570a53cabc7e1bb8f195fe08c (diff)
refactor, nicer errors
Diffstat (limited to 'texts.lua')
-rw-r--r--texts.lua35
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,
+}