[WIP] Dialeg. dialeg:draw()

This commit is contained in:
2026-04-21 22:11:38 +02:00
parent 75898372f9
commit a811ece34f
2 changed files with 70 additions and 37 deletions

View File

@@ -1,40 +1,65 @@
function dialog.new( _text, _actor ) dialeg={
return { list = {},
actor = _actor, }
text = _text,
time = 60, function dialeg.new( _text, _actor )
} table.insert(
dialeg.list,
{
actor= _actor,
text=_text,
time = 120,
w = math.floor(4.6*#_text),
h = 20,
} )
end end
function dialeg:draw( ) function dialeg:draw( )
local w = 50 local i = 1
local h = 20 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 x = 0
local y = 0 local y = 0
y = actor.y-20 y = d.actor.y-20
if actor.flip then if d.actor.flip then
x = actor.x-w x = d.actor.x-d.w
else else
x = actor.x+actor.w x = d.actor.x+d.actor.w
end end
x, y = viewp:screen_coords( x, y ) x, y = viewp:screen_coords( x, y )
draw.rrectf(x, y, w, h, 5, 2)
if actor.flip then draw.rrectf(x, y, d.w, d.h, 5, 2)
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) if d.actor.flip then
draw.line(x+w, y+h-1+5, x+w-14, y+h-1, 2) draw.line(x+d.w, y+d.h-1+5, x+d.w-20, y+d.h-1, 2)
draw.line(x+w, y+h-1+5, x+w-12, y+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 else
draw.line(x, y+h-1+5, x+20, y+h-1, 2) draw.line(x, y+d.h-1+5, x+20, y+d.h-1, 2)
draw.line(x, y+h-1+5, x+18, y+h-1, 2) draw.line(x, y+d.h-1+5, x+18, y+d.h-1, 2)
draw.line(x, y+h-1+5, x+14, y+h-1, 2) draw.line(x, y+d.h-1+5, x+14, y+d.h-1, 2)
draw.line(x, y+h-1+5, x+12, y+h-1, 2) draw.line(x, y+d.h-1+5, x+12, y+d.h-1, 2)
end end
local font_curr = font.current() local font_curr = font.current()
font.current(font_default) font.current(font_default)
draw.text(text, x+5,y+7, 16) draw.text(d.text, x+5,y+7, 16)
font.current(font_curr) font.current(font_curr)
d.time = d.time-1
i = i + 1
end
else
table.remove(self.list, i)
end
end
end end
return dialeg

View File

@@ -238,6 +238,8 @@ function world_draw()
end end
end end
dialeg:draw()
if stages.boss_loaded then stage_draw_middle() end if stages.boss_loaded then stage_draw_middle() end
cacau:draw() cacau:draw()
@@ -385,7 +387,13 @@ function special_keys()
-- boss.x_old = boss.x -- boss.x_old = boss.x
-- boss.x = boss.x+1 -- boss.x = boss.x+1
-- print_analisis() -- print_analisis()
dialeg_draw( "Hola mundo!", abad ) dialeg.new( "Hola mundo!", abad )
end
if key.press(key.F) then
-- boss.x_old = boss.x
-- boss.x = boss.x+1
-- print_analisis()
dialeg.new( "Ma cuando arribo a casa", premiere )
end end
if key.press(key.W) then if key.press(key.W) then
boss.y_old = boss.y boss.y_old = boss.y