40 lines
1.2 KiB
Lua
40 lines
1.2 KiB
Lua
game={
|
|
cam={x=0,y=0},
|
|
|
|
init=function()
|
|
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="jailer",x=6,y=9,o="r",gfx={x=32,y=0}})
|
|
update=game.update
|
|
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 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
|
|
} |