diff --git a/data/actors.lua b/data/actors.lua index c263b32..02c8c45 100644 --- a/data/actors.lua +++ b/data/actors.lua @@ -34,17 +34,32 @@ actors={ for i,v in ipairs(actors.list) do local frame=((v.dx+v.dy)%2)*16 if v.o=='u' then - sspr(v.gfx.x+frame,v.gfx.y+16,16,16,v.x*8-4+v.dx*2,v.y*8-12+v.dy*2,16,16,v.dy>1) + sspr(v.gfx.x+frame,v.gfx.y+16,16,16,v.x*8+v.dx*2,v.y*8-12+v.dy*2,16,16,v.dy>1) elseif v.o=='d' then - sspr(v.gfx.x+frame,v.gfx.y,16,16,v.x*8-4+v.dx*2,v.y*8-12+v.dy*2,16,16,-v.dy>2) + sspr(v.gfx.x+frame,v.gfx.y,16,16,v.x*8+v.dx*2,v.y*8-12+v.dy*2,16,16,-v.dy>2) elseif v.o=='l' then - sspr(v.gfx.x+frame,v.gfx.y+32,16,16,v.x*8-4+v.dx*2,v.y*8-12+v.dy*2,16,16) + sspr(v.gfx.x+frame,v.gfx.y+32,16,16,v.x*8+v.dx*2,v.y*8-12+v.dy*2,16,16) elseif v.o=='r' then - sspr(v.gfx.x+frame,v.gfx.y+32,16,16,v.x*8-4+v.dx*2,v.y*8-12+v.dy*2,16,16,true) + sspr(v.gfx.x+frame,v.gfx.y+32,16,16,v.x*8+v.dx*2,v.y*8-12+v.dy*2,16,16,true) end end end, + check_collision=function(x,y,o) + for i,actor in ipairs(actors.list) do + if o=='u' then + if actor.y==y-1 and (actor.x==x-1 or actor.x==x or actor.x==x+1) then return true end + elseif o=='d' then + if actor.y==y+1 and (actor.x==x-1 or actor.x==x or actor.x==x+1) then return true end + elseif o=='l' then + if actor.y==y and actor.x==x-2 then return true end + elseif o=='r' then + if actor.y==y and actor.x==x+2 then return true end + end + end + return false + end, + update=function() if actors.updating then return end actors.updating=true @@ -61,7 +76,9 @@ actors={ v.keys=nil if v.name == actors.main.name then local switch = switches.search(v.x,v.y) - if switch then switch.action() end + if switch then + if switch.action() then v.path=nil end + end end end if v.path and v.path.pos ~= #v.path.route then @@ -69,26 +86,30 @@ actors={ local step=string.sub(v.path.route,v.path.pos,v.path.pos) if step=='u' then v.o='u' - --check collision! - v.y=v.y-1 - v.dy=4 - needs_sorting=true + if not actors.check_collision(v.x,v.y,v.o) and not mapa.check_collision(v.x,v.y-1) then + v.y=v.y-1 + v.dy=4 + needs_sorting=true + end elseif step=='d' then v.o='d' - --check collision! - v.y=v.y+1 - v.dy=-4 - needs_sorting=true + if not actors.check_collision(v.x,v.y,v.o) and not mapa.check_collision(v.x,v.y+1) then + v.y=v.y+1 + v.dy=-4 + needs_sorting=true + end elseif step=='l' then v.o='l' - --check collision! - v.x=v.x-1 - v.dx=4 + if not actors.check_collision(v.x,v.y,v.o) and not mapa.check_collision(v.x-1,v.y) then + v.x=v.x-1 + v.dx=4 + end elseif step=='r' then v.o='r' - --check collision! - v.x=v.x+1 - v.dx=-4 + if not actors.check_collision(v.x,v.y,v.o) and not mapa.check_collision(v.x+1,v.y) then + v.x=v.x+1 + v.dx=-4 + end elseif step=='q' then v.o='u' elseif step=='a' then diff --git a/data/game.lua b/data/game.lua index a381699..a6737ff 100644 --- a/data/game.lua +++ b/data/game.lua @@ -39,6 +39,9 @@ game={ function() wait.start(1) end, function() balloon.show("IMBÈSIL...",2,"jailer",true,{x=5,w=7,h=1}) end }) + return true + else + return false end end }) diff --git a/data/mapa.lua b/data/mapa.lua index e13f84a..1082106 100644 --- a/data/mapa.lua +++ b/data/mapa.lua @@ -52,5 +52,9 @@ mapa={ end io.close(file) end + end, + + check_collision=function(x,y) + return mget(x,y) > 16 end } \ No newline at end of file diff --git a/data/test.map b/data/test.map index 4f419c9..10d4995 100644 --- a/data/test.map +++ b/data/test.map @@ -4,13 +4,13 @@ 17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17, 17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17, 17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17, -3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17, +28,29,28,29,28,29,28,29,28,29,28,29,28,29,28,29,28,29,28,29,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17, 23,24,23,24,19,20,21,22,23,24,23,24,23,24,19,20,21,22,23,24,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17, 39,40,41,42,35,36,37,38,39,40,39,40,41,42,35,36,37,38,39,40,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17, 55,57,58,59,51,52,53,54,55,56,57,58,59,56,51,52,53,54,55,56,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17, -100,73,74,75,100,100,100,100,100,100,73,74,75,100,100,100,100,100,100,100,100,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17, -100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17, -100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17, +1,7,8,9,1,1,1,1,1,1,7,8,9,1,1,1,1,1,1,1,100,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17, +1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,100,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17, +1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,100,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17, 17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17, 17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17, 17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17, diff --git a/data/tiles.gif b/data/tiles.gif index 52b1a22..a541a9d 100644 Binary files a/data/tiles.gif and b/data/tiles.gif differ