Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
Initial Commit
  • Loading branch information
sonic2kk authored and sonic2kk committed Aug 9, 2014
0 parents commit 030f1af
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions typo.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
typo = {}

function typo_new(text, delay, width, align, x, y, font)
local t = {
t = text,
delay = delay,
width = width,
align = align,
x = x,
y = y,
font = font,

string = {},
index = 1,
timer = 0,

text = ''
}

local i = 1

for c in text:gmatch('.') do
t.string[i] = c

i = i + 1
end

table.insert(typo, t)
end

function typo_update(dt)
for i,v in ipairs(typo) do
v.timer = v.timer + dt

if v.timer >= v.delay and v.index <= #v.string then
v.text = v.text .. tostring(v.string[v.index])

v.index = v.index + 1

v.timer = 0
end
end
end

function typo_draw()
for i,v in ipairs(typo) do
love.graphics.setFont(v.font)
love.graphics.printf(v.text, v.x, v.y, v.width, v.align)
end
end

0 comments on commit 030f1af

Please sign in to comment.