From 9cf27be5d337c539970feb56e9a9fa3f2e31c0ec Mon Sep 17 00:00:00 2001 From: matt-flaig Date: Mon, 7 Mar 2022 13:54:59 -0800 Subject: [PATCH] Fix collisions when moving from one-way to slopes When moving from one-way tiles to upward slopes, entities would get stuck at the edge of the slope and require upwards momentum to be able to continue moving forwards. --- lib/impact/collision-map.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/impact/collision-map.js b/lib/impact/collision-map.js index 23f5ddec..d8cf34af 100644 --- a/lib/impact/collision-map.js +++ b/lib/impact/collision-map.js @@ -90,9 +90,10 @@ ig.CollisionMap = ig.Map.extend({ for( var tileY = firstTileY; tileY < lastTileY; tileY++ ) { if( prevTileX != -1 ) { t = this.data[tileY][prevTileX]; - if( - t > 1 && t <= this.lastSlope && - this._checkTileDef(res, t, x, y, rvx, rvy, width, height, prevTileX, tileY) + if( + t > 1 && t <= this.lastSlope && + this._checkTileDef(res, t, x, y, rvx, rvy, width, height, prevTileX, tileY) && + res.collision.slope.ny !== 0 ) { break; } @@ -137,9 +138,11 @@ ig.CollisionMap = ig.Map.extend({ for( var tileX = firstTileX; tileX < lastTileX; tileX++ ) { if( prevTileY != -1 ) { t = this.data[prevTileY][tileX]; - if( + if( t > 1 && t <= this.lastSlope && - this._checkTileDef(res, t, x, y, rvx, rvy, width, height, tileX, prevTileY) ) { + this._checkTileDef(res, t, x, y, rvx, rvy, width, height, tileX, prevTileY) && + res.collision.slope.nx !== 0 + ) { break; } }