From 5e1c7fb4dde69b43f4993273e6a0ddf5560c2aad Mon Sep 17 00:00:00 2001 From: Mal Date: Sun, 26 Jan 2020 11:25:20 +0100 Subject: [PATCH] Wall collision fix. --- js/module.js | 5 ++--- js/retro/RetroArchitecture.js | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/js/module.js b/js/module.js index 7074b16..83cc694 100644 --- a/js/module.js +++ b/js/module.js @@ -97,7 +97,7 @@ function MainLoop(timestamp) ); if (wallLeft < lastWallLeft) { - mrCroc.position.x = lastWallLeft + 1; + mrCroc.position.x = lastWallLeft + mrCroc.getWidth() * 0.5 + 1; } } else if (KeyRight.isPressed()) { mrCroc.moveRight(timestamp, delta); @@ -108,7 +108,7 @@ function MainLoop(timestamp) ); if (wallRight > lastWallRight) { - mrCroc.position.x = lastWallRight - 1; + mrCroc.position.x = lastWallRight - mrCroc.getWidth() * 0.5 - 1; } } @@ -129,7 +129,6 @@ function MainLoop(timestamp) mrCroc.getPositionHeadLeft().draw(context); mrCroc.getPositionFootLeft().draw(context); */ - lastRendered = timestamp; } diff --git a/js/retro/RetroArchitecture.js b/js/retro/RetroArchitecture.js index a64691d..9a0de0a 100644 --- a/js/retro/RetroArchitecture.js +++ b/js/retro/RetroArchitecture.js @@ -116,7 +116,7 @@ export default class RetroArchitecture while (tilePosition !== null && tilePosition.x < this.columns) { if (this.matrix[tilePosition.y][tilePosition.x] !== null) { - return tilePosition.x * this.tileWidth - this.tileWidth * 0.5; + return tilePosition.x * this.tileWidth; } tilePosition.x++; @@ -131,7 +131,7 @@ export default class RetroArchitecture while (tilePosition !== null && tilePosition.x > 0) { if (this.matrix[tilePosition.y][tilePosition.x] !== null) { - return tilePosition.x * this.tileWidth + this.tileWidth * 1.5; + return tilePosition.x * this.tileWidth + this.tileWidth; } tilePosition.x--;