dialeg={ list = {}, } -- dialegs = {} -- function dialeg.update() -- for i,d in ipairs(dialegs) do -- if distancia(d.actor1, d.actor2, d.direccio)<=d.distancia and d.enabled then -- dialeg.new(d.text, d.actor1) -- d.enabled=false -- end -- end -- end -- function dialeg.new( _text, _actor ) -- print(_text) -- table.insert( -- dialeg.list, -- { -- actor= _actor, -- text=_text, -- time = 120, -- w = math.floor(4.6*#_text), -- h = 20, -- } ) -- end function dialeg.draw( ) local i = 1 while i <= #dialeg.list do local d = dialeg.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 end i = i + 1 else table.remove(dialeg.list, i) end end end return dialeg