-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |