From 7fed8669b1b486d1722e39f7fd68bb5d86d30d6e Mon Sep 17 00:00:00 2001 From: Yozzaxia1311 Date: Wed, 25 Nov 2020 22:56:24 -0500 Subject: [PATCH] properly checks wall during slope --- core/collision.lua | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/core/collision.lua b/core/collision.lua index 7caab3ec..1204f600 100644 --- a/core/collision.lua +++ b/core/collision.lua @@ -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