Files
jailsadventure2/data/game.lua

101 lines
3.5 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.add({name="estudiant",x=12,y=8,o="d",gfx={x=64,y=0}})
actors.hero="jailer"
update=game.update
--objects.collect({name="diskette",x=0,y=0})
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!!",10,"usufondo",false,{x=7,w=10,h=2}) end,
function() objects.collect({name="DISQUITO DE USUFONDO",x=0,y=0}) 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...",2,"jailer",true,{x=5,w=7,h=1}) end
})
end
end
})
fade.fadein()
end,
show_menu=function()
game.pause()
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() game.resume() end)
end,
update=function()
if game.paused then return end
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}
end
end
if btnp(KEY_ESCAPE) then
game.show_menu()
end
if beat() then actors.update() end
end,
pause=function()
game.paused = true
rectfill(9,84, 150, 128,6)
rect(9,84, 150, 128,8)
rect(8,83, 151, 129,6)
text("OBJECTES:",14,82,8)
setsource(objectes)
local x,y=15,90
for k,v in pairs(objects.list) do
sspr(v.x,v.y,16,16,x,y)
x=x+19
if x==148 then x,y=15,y+19 end
end
end,
resume=function()
game.paused = nil
end
}