- La càmara segueix al "heroi"

This commit is contained in:
2023-01-30 18:16:03 +01:00
parent 09bea06850
commit 3e608882c9
2 changed files with 10 additions and 4 deletions

View File

@@ -3,12 +3,19 @@ game={
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='rrrrura'}})
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)
@@ -16,7 +23,6 @@ game={
actors.draw()
camera(0,0)
local hero = actors.search("jailer")
if hero and not hero.path and hero.dx+hero.dy==0 then
if btn(KEY_DOWN) then
hero.path={pos=0,route='d'}