diff --git a/main.lua b/main.lua index f2b4c21..a18f297 100644 --- a/main.lua +++ b/main.lua @@ -7,7 +7,7 @@ require("maploader") points=0 mp={ {0,0,0,0,0,0,0,0,0}, - {0,0,0,0,0,0,0,"e",0}, + {0,0,0,0,0,0,"e",0,0}, {0,0,0,0,1,1,1,1,1}, {0,0,0,0,0,0,0,0,0}, {2,2,2,2,0,0,0,0,0}, @@ -205,14 +205,19 @@ function love.update(dt) en.x=en.x+2*en.dir for _,ti in pairs(t.tiles) do if en.y+en.h>=ti.y and en.y+en.h<=ti.y+ti.h then - if ti.x==en.x and ti.y==en.y+en.h then + if ti.x>=en.x then en.dir=1 - elseif ti.x+ti.w==en.x+en.w then + elseif ti.x+ti.w<=en.x+en.w then en.dir=-1 end en.onground=true end end + if not en.onground then + en.dy=en.dy+1 + en.y=en.y+en.dy + end + en.onground=false end if player.cooldown~=0 then player.cooldown=player.cooldown-1 @@ -220,13 +225,6 @@ function love.update(dt) if #e.enemies==0 and not lose and not win then win=true end - for _,ene in pairs(e.enemies) do - if not ene.onground then - ene.dy=ene.dy+1 - ene.y=ene.y+ene.dy - end - ene.onground=false - end player.onground=false if player.x==0 then moveleft=false diff --git a/maploader.lua b/maploader.lua index 3776b55..99d234e 100644 --- a/maploader.lua +++ b/maploader.lua @@ -26,7 +26,6 @@ function loadmap(map) t:new(x, (c*32)-32, (q*32)-32) elseif x=="e" then e:new((c*32)-32,(q*32)-32,32,32,3) - print(tostring(q..c)) end end end