[WIP] Dialeg. dialeg:draw()
This commit is contained in:
@@ -1,40 +1,65 @@
|
||||
function dialog.new( _text, _actor )
|
||||
return {
|
||||
actor = _actor,
|
||||
text = _text,
|
||||
time = 60,
|
||||
}
|
||||
dialeg={
|
||||
list = {},
|
||||
}
|
||||
|
||||
function dialeg.new( _text, _actor )
|
||||
table.insert(
|
||||
dialeg.list,
|
||||
{
|
||||
actor= _actor,
|
||||
text=_text,
|
||||
time = 120,
|
||||
w = math.floor(4.6*#_text),
|
||||
h = 20,
|
||||
} )
|
||||
end
|
||||
|
||||
function dialeg:draw( )
|
||||
local w = 50
|
||||
local h = 20
|
||||
local x = 0
|
||||
local y = 0
|
||||
local i = 1
|
||||
while i <= #self.list do
|
||||
local d = self.list[i]
|
||||
|
||||
if d.time>0 and d.actor then
|
||||
if viewp:inside(d.actor.x, d.actor.y, d.actor.w, d.actor.h) then
|
||||
local x = 0
|
||||
local y = 0
|
||||
|
||||
y = d.actor.y-20
|
||||
if d.actor.flip then
|
||||
x = d.actor.x-d.w
|
||||
else
|
||||
x = d.actor.x+d.actor.w
|
||||
end
|
||||
|
||||
x, y = viewp:screen_coords( x, y )
|
||||
|
||||
draw.rrectf(x, y, d.w, d.h, 5, 2)
|
||||
|
||||
if d.actor.flip then
|
||||
draw.line(x+d.w, y+d.h-1+5, x+d.w-20, y+d.h-1, 2)
|
||||
draw.line(x+d.w, y+d.h-1+5, x+d.w-18, y+d.h-1, 2)
|
||||
draw.line(x+d.w, y+d.h-1+5, x+d.w-14, y+d.h-1, 2)
|
||||
draw.line(x+d.w, y+d.h-1+5, x+d.w-12, y+d.h-1, 2)
|
||||
else
|
||||
draw.line(x, y+d.h-1+5, x+20, y+d.h-1, 2)
|
||||
draw.line(x, y+d.h-1+5, x+18, y+d.h-1, 2)
|
||||
draw.line(x, y+d.h-1+5, x+14, y+d.h-1, 2)
|
||||
draw.line(x, y+d.h-1+5, x+12, y+d.h-1, 2)
|
||||
end
|
||||
|
||||
local font_curr = font.current()
|
||||
font.current(font_default)
|
||||
draw.text(d.text, x+5,y+7, 16)
|
||||
font.current(font_curr)
|
||||
|
||||
d.time = d.time-1
|
||||
|
||||
i = i + 1
|
||||
end
|
||||
else
|
||||
table.remove(self.list, i)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
y = actor.y-20
|
||||
if actor.flip then
|
||||
x = actor.x-w
|
||||
else
|
||||
x = actor.x+actor.w
|
||||
end
|
||||
|
||||
x, y = viewp:screen_coords( x, y )
|
||||
draw.rrectf(x, y, w, h, 5, 2)
|
||||
if actor.flip then
|
||||
draw.line(x+w, y+h-1+5, x+w-20, y+h-1, 2)
|
||||
draw.line(x+w, y+h-1+5, x+w-18, y+h-1, 2)
|
||||
draw.line(x+w, y+h-1+5, x+w-14, y+h-1, 2)
|
||||
draw.line(x+w, y+h-1+5, x+w-12, y+h-1, 2)
|
||||
else
|
||||
draw.line(x, y+h-1+5, x+20, y+h-1, 2)
|
||||
draw.line(x, y+h-1+5, x+18, y+h-1, 2)
|
||||
draw.line(x, y+h-1+5, x+14, y+h-1, 2)
|
||||
draw.line(x, y+h-1+5, x+12, y+h-1, 2)
|
||||
end
|
||||
|
||||
local font_curr = font.current()
|
||||
font.current(font_default)
|
||||
draw.text(text, x+5,y+7, 16)
|
||||
font.current(font_curr)
|
||||
end
|
||||
return dialeg
|
||||
Reference in New Issue
Block a user