Compare commits
2 Commits
ac1b6cb21e
...
2fb0749cf7
| Author | SHA1 | Date | |
|---|---|---|---|
| 2fb0749cf7 | |||
| f03ed38d77 |
@@ -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,16 @@ actors={
|
||||
elseif step=='p' then
|
||||
v.o='r'
|
||||
end
|
||||
|
||||
if v.path.pos == #v.path.route then
|
||||
v.path=nil
|
||||
game.update()
|
||||
scene.cont()
|
||||
if v.name == actors.hero then
|
||||
local switch = switches.search(v.x,v.y)
|
||||
if switch then switch.action() end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
if v.dx > 0 then
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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=switches.lua,scene.lua,balloon.lua,actors.lua,game.lua,mapa.lua,editor.lua,textbox.lua,menu.lua,main.lua
|
||||
|
||||
@@ -2,10 +2,25 @@ game={
|
||||
cam={x=0,y=0},
|
||||
|
||||
init=function()
|
||||
flags={}
|
||||
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.hero="jailer"
|
||||
|
||||
update=game.update
|
||||
|
||||
switches.add({x=8,y=8,w=1,h=3,action=
|
||||
function()
|
||||
if not flags.usu1 then
|
||||
flags.usu1=true
|
||||
scene.start({
|
||||
function() actors.search("usufondo").path={pos=0,route='rrrruro'} end,
|
||||
function() balloon.show("HOLA\nQUE TAL?","usufondo",true) end
|
||||
})
|
||||
end
|
||||
end
|
||||
})
|
||||
end,
|
||||
|
||||
update=function()
|
||||
@@ -23,9 +38,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
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
|
||||
}
|
||||
18
data/switches.lua
Normal file
18
data/switches.lua
Normal file
@@ -0,0 +1,18 @@
|
||||
switches={
|
||||
list={},
|
||||
|
||||
add=function(switch)
|
||||
if not switch.w then switch.w=1 end
|
||||
if not switch.h then switch.h=1 end
|
||||
table.insert(switches.list, switch)
|
||||
end,
|
||||
|
||||
search=function(x,y)
|
||||
for i,v in ipairs(switches.list) do
|
||||
if x>=v.x and x<v.x+v.w and y>=v.y and y<v.y+v.h then
|
||||
return v
|
||||
end
|
||||
end
|
||||
return nil
|
||||
end,
|
||||
}
|
||||
Reference in New Issue
Block a user