const Camera = { x: 0, y: 0, centerOn(hex) { const pixelCoord = HexGrid.toPixel(hex); this.x = pixelCoord.x - state.canvas.width / 2; this.y = pixelCoord.y - state.canvas.height / 2; }, smoothFollow(target) { const targetPixel = HexGrid.toPixel(target); const screenX = targetPixel.x - this.x; const screenY = 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; } 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; } } };