diff options
author | elioat <elioat@tilde.institute> | 2024-12-28 07:47:55 -0500 |
---|---|---|
committer | elioat <elioat@tilde.institute> | 2024-12-28 07:47:55 -0500 |
commit | 4f1da58e67b3438c00fb09051bd3ccb6213d298d (patch) | |
tree | aed25e4fd0bb7922bd81eb7436ddfb52a1e75607 /html/rogue/js/camera.js | |
parent | d17d85553a72e40ac390238dab5c03dfa9f567ee (diff) | |
download | tour-4f1da58e67b3438c00fb09051bd3ccb6213d298d.tar.gz |
*
Diffstat (limited to 'html/rogue/js/camera.js')
-rw-r--r-- | html/rogue/js/camera.js | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/html/rogue/js/camera.js b/html/rogue/js/camera.js index aaeeea9..2cb84d1 100644 --- a/html/rogue/js/camera.js +++ b/html/rogue/js/camera.js @@ -10,25 +10,23 @@ const Camera = { smoothFollow(target) { const targetPixel = HexGrid.toPixel(target); - const screenX = targetPixel.x - this.x; - const screenY = targetPixel.y - this.y; + const screenX = Math.round(targetPixel.x - this.x); + const screenY = Math.round(targetPixel.y - this.y); const centerX = state.canvas.width / 2; const centerY = state.canvas.height / 2; - // Distance from center of the screen const deltaX = screenX - centerX; const deltaY = screenY - centerY; - // Only move the camera if the player is outside of the deadzone if (Math.abs(deltaX) > Config.camera.DEADZONE_X) { const adjustX = deltaX - (deltaX > 0 ? Config.camera.DEADZONE_X : -Config.camera.DEADZONE_X); - this.x += adjustX * Config.camera.FOLLOW_SPEED; + this.x += Math.round(adjustX * Config.camera.FOLLOW_SPEED); } if (Math.abs(deltaY) > Config.camera.DEADZONE_Y) { const adjustY = deltaY - (deltaY > 0 ? Config.camera.DEADZONE_Y : -Config.camera.DEADZONE_Y); - this.y += adjustY * Config.camera.FOLLOW_SPEED; + this.y += Math.round(adjustY * Config.camera.FOLLOW_SPEED); } } }; \ No newline at end of file |