fix: smooth cam

This commit is contained in:
cha0s 2024-07-01 13:44:16 -05:00
parent b9a86312de
commit a8d2b32938

View File

@ -31,10 +31,10 @@ export default class FollowCamera extends System {
if (Camera.x === px && Camera.y === py) {
return;
}
if (Math.abs(Camera.x - px) < 0.1) {
if (Math.abs(Camera.x - px) < 0.01) {
Camera.x = px;
}
if (Math.abs(Camera.y - py) < 0.1) {
if (Math.abs(Camera.y - py) < 0.01) {
Camera.y = py;
}
const [dx, dy] = [
@ -42,8 +42,8 @@ export default class FollowCamera extends System {
(py - Camera.y) * portion,
];
[Camera.x, Camera.y] = [
Camera.x + (Math.sign(dx) * Math.max(0.1, Math.abs(dx))),
Camera.y + (Math.sign(dy) * Math.max(0.1, Math.abs(dy))),
Camera.x + (Math.sign(dx) * Math.max(0.01, Math.abs(dx))),
Camera.y + (Math.sign(dy) * Math.max(0.01, Math.abs(dy))),
];
}
}