- Al baló de text se li pot pasar un tamany i posició
- Els dialegs avancen al pulsar un botó
This commit is contained in:
@@ -3,11 +3,19 @@ balloon={
|
|||||||
pos=1,
|
pos=1,
|
||||||
cursor={x=0,y=0},
|
cursor={x=0,y=0},
|
||||||
old_update=nil,
|
old_update=nil,
|
||||||
|
rect=nil,
|
||||||
|
|
||||||
show=function(txt,actorname,below)
|
show=function(txt,actorname,below,rectangle)
|
||||||
local actor = actors.search(actorname)
|
local actor = actors.search(actorname)
|
||||||
if not actor then return end
|
if not actor then return end
|
||||||
|
|
||||||
|
if rectangle==nil then
|
||||||
|
balloon.rect={x=8,y=actor.y*8-4,w=144,h=35}
|
||||||
|
else
|
||||||
|
balloon.rect=rectangle
|
||||||
|
balloon.rect.y=actor.y*8-4
|
||||||
|
end
|
||||||
|
|
||||||
balloon.text=txt
|
balloon.text=txt
|
||||||
balloon.pos=1
|
balloon.pos=1
|
||||||
|
|
||||||
@@ -17,43 +25,44 @@ balloon={
|
|||||||
local pos,height=actor.x*8+4,actor.y*8-4
|
local pos,height=actor.x*8+4,actor.y*8-4
|
||||||
|
|
||||||
if below==nil or below==false then
|
if below==nil or below==false then
|
||||||
height=height-51
|
balloon.rect.y=balloon.rect.y-51
|
||||||
rectfill(9,height+1,153,height+36,5)
|
local x,y,w,h=balloon.rect.x,balloon.rect.y,balloon.rect.w,balloon.rect.h
|
||||||
rectfill(8,height,152,height+35,8)
|
rectfill(x+1,y+1,x+w+1,y+h+1,5)
|
||||||
rect(8,height,152,height+35,6)
|
rectfill(x,y,x+w,y+h,8)
|
||||||
|
rect(x,y,x+y,y+h,6)
|
||||||
|
|
||||||
if pos<80 then
|
if pos<80 then
|
||||||
for i=0,4 do rect(pos,height+35+(4-i),pos+i,height+35+(4-i),8) end
|
for i=0,4 do rect(pos,y+h+(4-i),pos+i,y+h+(4-i),8) end
|
||||||
line(pos-1,height+36,pos-1,height+41,6)
|
line(pos-1,y+h+1,pos-1,y+h+6,6)
|
||||||
line(pos+4,height+36,pos-1,height+41,6)
|
line(pos+4,y+h+1,pos-1,y+h+6,6)
|
||||||
else
|
else
|
||||||
pos=pos-5
|
pos=pos-5
|
||||||
for i=0,4 do rect(pos+i,height+35+i,pos+4,height+35+i,8) end
|
for i=0,4 do rect(pos+i,y+h+i,pos+4,y+h+i,8) end
|
||||||
line(pos+5,height+36,pos+5,height+41,6)
|
line(pos+5,y+h+1,pos+5,y+h+6,6)
|
||||||
line(pos,height+36,pos+5,height+41,6)
|
line(pos,y+h+1,pos+5,y+h+6,6)
|
||||||
end
|
end
|
||||||
height=height+7
|
height=height+7
|
||||||
else
|
else
|
||||||
height=height+16
|
balloon.rect.y=balloon.rect.y+16
|
||||||
rectfill(9,height+1,153,height+35,5)
|
local x,y,w,h=balloon.rect.x,balloon.rect.y,balloon.rect.w,balloon.rect.h
|
||||||
rectfill(8,height,152,height+36,8)
|
rectfill(x+1,y+1,x+w+1,y+h+1,5)
|
||||||
rect(8,height,152,height+36,6)
|
rectfill(x,y,x+w,y+h,8)
|
||||||
|
rect(x,y,x+w,y+h,6)
|
||||||
|
|
||||||
if pos<80 then
|
if pos<80 then
|
||||||
for i=0,4 do rect(pos,height-(4-i),pos+i,height-(4-i),8) end
|
for i=0,4 do rect(pos,y-(4-i),pos+i,y-(4-i),8) end
|
||||||
line(pos-1,height,pos-1,height-6,6)
|
line(pos-1,y,pos-1,y-6,6)
|
||||||
line(pos+5,height,pos-1,height-6,6)
|
line(pos+5,y,pos-1,y-6,6)
|
||||||
else
|
else
|
||||||
pos=pos-5
|
pos=pos-5
|
||||||
for i=0,4 do rect(pos+i,height-i,pos+4,height-i,8) end
|
for i=0,4 do rect(pos+i,y-i,pos+4,y-i,8) end
|
||||||
line(pos+5,height,pos+5,height-6,6)
|
line(pos+5,y,pos+5,y-6,6)
|
||||||
line(pos-1,height,pos+5,height-6,6)
|
line(pos-1,y,pos+5,y-6,6)
|
||||||
end
|
end
|
||||||
|
|
||||||
height=height+7
|
height=height+7
|
||||||
end
|
end
|
||||||
|
|
||||||
balloon.cursor={x=16,y=height}
|
balloon.cursor={x=balloon.rect.x+8,y=balloon.rect.y+7}
|
||||||
--text("12345678901234567890123456789012\n3",16,height, 2)
|
--text("12345678901234567890123456789012\n3",16,height, 2)
|
||||||
--text("UNO DOS TRES",16,height+9, 2)
|
--text("UNO DOS TRES",16,height+9, 2)
|
||||||
--text("UNO DOS TRES",16,height+18, 2)
|
--text("UNO DOS TRES",16,height+18, 2)
|
||||||
@@ -66,21 +75,38 @@ balloon={
|
|||||||
end,
|
end,
|
||||||
|
|
||||||
update=function()
|
update=function()
|
||||||
|
if balloon.pos<0 and btnp(KEY_SPACE) then
|
||||||
|
update=balloon.old_update
|
||||||
|
end
|
||||||
|
|
||||||
if not beat() then return end
|
if not beat() then return end
|
||||||
|
|
||||||
local char=string.sub(balloon.text,balloon.pos,balloon.pos)
|
if balloon.pos<0 then
|
||||||
if char=='' then
|
local col=8
|
||||||
-- final
|
if flr(time()*4)%2==0 then col=10 end
|
||||||
update=balloon.old_update
|
local x,y=balloon.rect.x+balloon.rect.w-8, balloon.rect.y+balloon.rect.h-6
|
||||||
elseif char=='\n' then
|
line(x,y,x+4,y,col)
|
||||||
-- salt de linea
|
line(x+1,y+1,x+3,y+1,col)
|
||||||
balloon.pos=balloon.pos+1
|
line(x+2,y+2,x+2,y+2,col)
|
||||||
balloon.cursor.x=16
|
if btnp(KEY_SPACE) then
|
||||||
balloon.cursor.y=balloon.cursor.y+9
|
update=balloon.old_update
|
||||||
else
|
end
|
||||||
text(char,balloon.cursor.x,balloon.cursor.y,2)
|
else
|
||||||
balloon.pos=balloon.pos+1
|
local char=string.sub(balloon.text,balloon.pos,balloon.pos)
|
||||||
balloon.cursor.x=balloon.cursor.x+4
|
if char=='' then
|
||||||
|
-- final
|
||||||
|
balloon.pos=-1
|
||||||
|
--update=balloon.old_update
|
||||||
|
elseif char=='\n' then
|
||||||
|
-- salt de linea
|
||||||
|
balloon.pos=balloon.pos+1
|
||||||
|
balloon.cursor.x=balloon.rect.x+8
|
||||||
|
balloon.cursor.y=balloon.cursor.y+9
|
||||||
|
else
|
||||||
|
text(char,balloon.cursor.x,balloon.cursor.y,2)
|
||||||
|
balloon.pos=balloon.pos+1
|
||||||
|
balloon.cursor.x=balloon.cursor.x+4
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user