74 lines
2.8 KiB
Lua
74 lines
2.8 KiB
Lua
game={
|
|
cam={x=0,y=0},
|
|
|
|
init=function()
|
|
flags={}
|
|
mapa.load("test.map")
|
|
|
|
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.add({name="usufondo",x=16,y=8,o="d",gfx={x=0,y=0}}) scene.cont() end,
|
|
function() wait.start(1) end,
|
|
function() actors.search("usufondo").path={pos=0,route='dlllll'} end,
|
|
function() balloon.show("HOY NO HAY JAIL!\nTU MISMO!!","usufondo",false,{x=7,w=10,h=2}) end,
|
|
function() actors.search("usufondo").path={pos=0,route='rrrrru'} end,
|
|
function() wait.start(0.5) end,
|
|
function() actors.remove("usufondo") scene.cont() end,
|
|
function() wait.start(1) end,
|
|
function() balloon.show("IMBÈSIL...","jailer",true,{x=5,w=7,h=1}) end
|
|
})
|
|
end
|
|
end
|
|
})
|
|
|
|
fade.fadein()
|
|
end,
|
|
|
|
show_menu=function()
|
|
menu.show({ {"GUARDAR PARTIDA", editor.new},
|
|
{"CARREGAR PARTIDA", function() textbox.show("FILENAME TO LOAD:",editor.load, mapa.name) end},
|
|
{"EIXIR", function() if mapa.name~=nil then editor.save(mapa.name) else textbox.show("FILENAME TO SAVE:",editor.save, mapa.name) end end},
|
|
{"EXIT", main_init},
|
|
}, function()editor.paused=false end)
|
|
end,
|
|
|
|
update=function()
|
|
local hero = actors.search("jailer")
|
|
if hero then
|
|
game.cam.x = hero.x*8 + hero.dx*2 - 80
|
|
if game.cam.x < 0 then game.cam.x=0 end
|
|
game.cam.y = hero.y*8 + hero.dy*2 - 72
|
|
if game.cam.y < 0 then game.cam.y=0 end
|
|
end
|
|
camera(game.cam.x, game.cam.y)
|
|
setsource(tiles)
|
|
map(0,0,0,0,mapa.w, mapa.h)
|
|
setsource(sprites)
|
|
actors.draw()
|
|
camera(0,0)
|
|
|
|
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',keys=true}
|
|
elseif btn(KEY_UP) then
|
|
hero.path={pos=0,route='u',keys=true}
|
|
elseif btn(KEY_LEFT) then
|
|
hero.path={pos=0,route='l',keys=true}
|
|
elseif btn(KEY_RIGHT) then
|
|
hero.path={pos=0,route='r',keys=true}
|
|
elseif btnp(KEY_ESCAPE) then
|
|
game.show_menu()
|
|
end
|
|
end
|
|
|
|
if beat() then actors.update() end
|
|
end
|
|
} |