diff --git a/data/actors.lua b/data/actors.lua index 7db946c..ac63ea5 100644 --- a/data/actors.lua +++ b/data/actors.lua @@ -37,7 +37,6 @@ actors={ if v.path then v.path.pos=v.path.pos+1 local step=string.sub(v.path.route,v.path.pos,v.path.pos) - if v.path.pos == #v.path.route then v.path=nil end if step=='u' then --check collision! v.y=v.y-1 @@ -69,6 +68,12 @@ actors={ elseif step=='p' then v.o='r' end + + if v.path.pos == #v.path.route then + v.path=nil + game.update() + scene.cont() + end end end if v.dx > 0 then diff --git a/data/balloon.lua b/data/balloon.lua index 241fbae..7dd3507 100644 --- a/data/balloon.lua +++ b/data/balloon.lua @@ -68,15 +68,10 @@ balloon={ --text("UNO DOS TRES",16,height+18, 2) end, - draw=function() - if ballon.text then - - end - end, - update=function() - if balloon.pos<0 and btnp(KEY_SPACE) then + if balloon.pos<0 and anykey() then update=balloon.old_update + scene.cont() end if not beat() then return end diff --git a/data/game.ini b/data/game.ini index 4e46ec7..fe16776 100644 --- a/data/game.ini +++ b/data/game.ini @@ -3,4 +3,4 @@ config=ja2 width=160 height=144 zoom=5 -files=balloon.lua,actors.lua,game.lua,mapa.lua,editor.lua,textbox.lua,menu.lua,main.lua +files=scene.lua,balloon.lua,actors.lua,game.lua,mapa.lua,editor.lua,textbox.lua,menu.lua,main.lua diff --git a/data/game.lua b/data/game.lua index 706b668..e2969b0 100644 --- a/data/game.lua +++ b/data/game.lua @@ -3,9 +3,12 @@ game={ init=function() mapa.load("test.map") - actors.add({name="usufondo",x=11,y=9,o="r",gfx={x=0,y=0},path={pos=0,route='rrrruro'}}) + actors.add({name="usufondo",x=11,y=9,o="r",gfx={x=0,y=0}}) actors.add({name="jailer",x=6,y=9,o="r",gfx={x=32,y=0}}) update=game.update + + scene.start({function() actors.search("usufondo").path={pos=0,route='rrrruro'} end, + function() balloon.show("HOLA\nQUE TAL?","usufondo",true) end }) end, update=function() @@ -23,9 +26,7 @@ game={ actors.draw() camera(0,0) - balloon.show("HOLA\nQUE TAL?", "usufondo",true) - - if hero and not hero.path and hero.dx+hero.dy==0 then + if not scene.script and hero and not hero.path and hero.dx+hero.dy==0 then if btn(KEY_DOWN) then hero.path={pos=0,route='d'} elseif btn(KEY_UP) then diff --git a/data/scene.lua b/data/scene.lua new file mode 100644 index 0000000..0209505 --- /dev/null +++ b/data/scene.lua @@ -0,0 +1,20 @@ +scene={ + script=nil, + pos=0, + + start=function(script) + scene.pos=0 + scene.script=script + scene.cont() + end, + + cont=function() + if scene.script==nil then return end + scene.pos=scene.pos+1 + if scene.script[scene.pos]==nil then + scene.script=nil + return + end + scene.script[scene.pos]() + end +} \ No newline at end of file