- creat el object "scene", ja funcional

This commit is contained in:
2023-01-31 15:20:19 +01:00
parent ac1b6cb21e
commit f03ed38d77
5 changed files with 34 additions and 13 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

20
data/scene.lua Normal file
View File

@@ -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
}