Skip to content

Commit

Permalink
properly checks wall during slope
Browse files Browse the repository at this point in the history
  • Loading branch information
Yozzaxia1311 committed Nov 26, 2020
1 parent 36e504e commit 7fed866
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions core/collision.lua
Original file line number Diff line number Diff line change
Expand Up @@ -453,21 +453,29 @@ function collision.generalCollision(self, noSlope)
local dst = math.min(math.abs(xsl), 128)
local yTolerance = math.ceil(math.abs(xsl)) * collision.maxSlope

while xStep ~= dst do
while true do
if self:collisionNumber(solid, xsl - xStep, -yStep) == 0 then
self.transform.x = self.transform.x + xsl - xStep
self.transform.y = self.transform.y - yStep
self.velocity.velx = self.xColl
self.xColl = 0
if xStep == 0 then
self.velocity.velx = self.xColl
self.xColl = 0
end
break
elseif self:collisionNumber(solid, xsl - xStep, yStep) == 0 then
self.transform.x = self.transform.x + xsl - xStep
self.transform.y = self.transform.y + yStep
self.velocity.velx = self.xColl
self.xColl = 0
if xStep == 0 then
self.velocity.velx = self.xColl
self.xColl = 0
end
break
end
if yStep > yTolerance then
if xStep == dst then
break
end

yStep = 1
xStep = math.min(xStep + 1, dst)
else
Expand Down

0 comments on commit 7fed866

Please sign in to comment.