- Implementat el moviment dels actors amb rutes
- També el moviment amb teclat del "heroi"
This commit is contained in:
@@ -3,12 +3,32 @@ 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="jailer",x=6,y=9,o="r",gfx={x=32,y=0}})
|
||||
update=game.update
|
||||
end,
|
||||
|
||||
update=function()
|
||||
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)
|
||||
|
||||
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'}
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user