Files
jailsadventure2/data/game.lua

55 lines
1.7 KiB
Lua

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}})
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()
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'}
elseif btn(KEY_UP) then
hero.path={pos=0,route='u'}
elseif btn(KEY_LEFT) then
hero.path={pos=0,route='l'}
elseif btn(KEY_RIGHT) then
hero.path={pos=0,route='r'}
end
end
if beat() then actors.update() end
end
}