parent
cd0190f065
commit
705d07abb6
1 changed files with 16 additions and 4 deletions
|
@ -106,13 +106,25 @@ function Hitbox2D:checkCollision(dx, dy, filter)
|
||||||
local nx, ny = self.ox + dx, self.oy + dy
|
local nx, ny = self.ox + dx, self.oy + dy
|
||||||
if (self.owner.useTileCollision and self.world.map.supportTileCollision) then
|
if (self.owner.useTileCollision and self.world.map.supportTileCollision) then
|
||||||
if (self:checkTileCollision(nx, self.y)) then
|
if (self:checkTileCollision(nx, self.y)) then
|
||||||
nx = self.x + 1
|
nx = self.x
|
||||||
nx = math.floor(nx / 16) * 16
|
local relx = dx - self.x
|
||||||
|
for i = 1, math.ceil(math.abs(relx)), 1 do
|
||||||
|
local nnx = self.x + i * utils.math.sign(relx)
|
||||||
|
if (not self:checkTileCollision(nnx, self.y)) then
|
||||||
|
nx = nnx
|
||||||
|
end
|
||||||
|
end
|
||||||
self.owner.xsp = 0
|
self.owner.xsp = 0
|
||||||
end
|
end
|
||||||
if (self:checkTileCollision(self.x, ny)) then
|
if (self:checkTileCollision(self.x, ny)) then
|
||||||
ny = self.y + 1
|
ny = self.y
|
||||||
ny = math.floor(ny / 16) * 16
|
local rely = dy - self.y
|
||||||
|
for i = 1, math.ceil(math.abs(rely)), 1 do
|
||||||
|
local nny = self.y + i * utils.math.sign(rely)
|
||||||
|
if (not self:checkTileCollision(self.x, nny)) then
|
||||||
|
ny = nny
|
||||||
|
end
|
||||||
|
end
|
||||||
self.owner.ysp = 0
|
self.owner.ysp = 0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue