- creat el object "scene", ja funcional
This commit is contained in:
@@ -37,7 +37,6 @@ actors={
|
|||||||
if v.path then
|
if v.path then
|
||||||
v.path.pos=v.path.pos+1
|
v.path.pos=v.path.pos+1
|
||||||
local step=string.sub(v.path.route,v.path.pos,v.path.pos)
|
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
|
if step=='u' then
|
||||||
--check collision!
|
--check collision!
|
||||||
v.y=v.y-1
|
v.y=v.y-1
|
||||||
@@ -69,6 +68,12 @@ actors={
|
|||||||
elseif step=='p' then
|
elseif step=='p' then
|
||||||
v.o='r'
|
v.o='r'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if v.path.pos == #v.path.route then
|
||||||
|
v.path=nil
|
||||||
|
game.update()
|
||||||
|
scene.cont()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if v.dx > 0 then
|
if v.dx > 0 then
|
||||||
|
|||||||
@@ -68,15 +68,10 @@ balloon={
|
|||||||
--text("UNO DOS TRES",16,height+18, 2)
|
--text("UNO DOS TRES",16,height+18, 2)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
draw=function()
|
|
||||||
if ballon.text then
|
|
||||||
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
|
|
||||||
update=function()
|
update=function()
|
||||||
if balloon.pos<0 and btnp(KEY_SPACE) then
|
if balloon.pos<0 and anykey() then
|
||||||
update=balloon.old_update
|
update=balloon.old_update
|
||||||
|
scene.cont()
|
||||||
end
|
end
|
||||||
|
|
||||||
if not beat() then return end
|
if not beat() then return end
|
||||||
|
|||||||
@@ -3,4 +3,4 @@ config=ja2
|
|||||||
width=160
|
width=160
|
||||||
height=144
|
height=144
|
||||||
zoom=5
|
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
|
||||||
|
|||||||
@@ -3,9 +3,12 @@ game={
|
|||||||
|
|
||||||
init=function()
|
init=function()
|
||||||
mapa.load("test.map")
|
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}})
|
actors.add({name="jailer",x=6,y=9,o="r",gfx={x=32,y=0}})
|
||||||
update=game.update
|
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,
|
end,
|
||||||
|
|
||||||
update=function()
|
update=function()
|
||||||
@@ -23,9 +26,7 @@ game={
|
|||||||
actors.draw()
|
actors.draw()
|
||||||
camera(0,0)
|
camera(0,0)
|
||||||
|
|
||||||
balloon.show("HOLA\nQUE TAL?", "usufondo",true)
|
if not scene.script and hero and not hero.path and hero.dx+hero.dy==0 then
|
||||||
|
|
||||||
if hero and not hero.path and hero.dx+hero.dy==0 then
|
|
||||||
if btn(KEY_DOWN) then
|
if btn(KEY_DOWN) then
|
||||||
hero.path={pos=0,route='d'}
|
hero.path={pos=0,route='d'}
|
||||||
elseif btn(KEY_UP) then
|
elseif btn(KEY_UP) then
|
||||||
|
|||||||
20
data/scene.lua
Normal file
20
data/scene.lua
Normal 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
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user