Prevent objects from sinking into tilemaps at low frame rates.

Because `blocked` would be set by the first collision,
repeated steps would then skip it, and allow gravity or acceleration
to ignore tiles in that direction for those steps.
This commit is contained in:
Ben Richards 2019-08-29 09:56:34 +12:00
parent 24f0187028
commit fd0dd79417
2 changed files with 4 additions and 4 deletions

View file

@ -39,7 +39,7 @@ var TileCheckX = function (body, tile, tileLeft, tileRight, tileBias, isLayer)
collideRight = true;
}
if (body.deltaX() < 0 && !body.blocked.left && collideRight && body.checkCollision.left)
if (body.deltaX() < 0 && collideRight && body.checkCollision.left)
{
// Body is moving LEFT
if (faceRight && body.x < tileRight)
@ -52,7 +52,7 @@ var TileCheckX = function (body, tile, tileLeft, tileRight, tileBias, isLayer)
}
}
}
else if (body.deltaX() > 0 && !body.blocked.right && collideLeft && body.checkCollision.right)
else if (body.deltaX() > 0 && collideLeft && body.checkCollision.right)
{
// Body is moving RIGHT
if (faceLeft && body.right > tileLeft)

View file

@ -39,7 +39,7 @@ var TileCheckY = function (body, tile, tileTop, tileBottom, tileBias, isLayer)
collideDown = true;
}
if (body.deltaY() < 0 && !body.blocked.up && collideDown && body.checkCollision.up)
if (body.deltaY() < 0 && collideDown && body.checkCollision.up)
{
// Body is moving UP
if (faceBottom && body.y < tileBottom)
@ -52,7 +52,7 @@ var TileCheckY = function (body, tile, tileTop, tileBottom, tileBias, isLayer)
}
}
}
else if (body.deltaY() > 0 && !body.blocked.down && collideUp && body.checkCollision.down)
else if (body.deltaY() > 0 && collideUp && body.checkCollision.down)
{
// Body is moving DOWN
if (faceTop && body.bottom > tileTop)