fix: Optimize player spawn, camera zoom, and performance to reduce lag

This commit is contained in:
Kacper Kostka (aider)
2025-04-05 18:06:39 +02:00
parent 85a96f153f
commit ad90b9320f
3 changed files with 15 additions and 10 deletions

View File

@@ -177,9 +177,9 @@ class Player extends Entity {
const targetOffsetX = this.x - (canvas.width / PIXEL_SIZE / 2);
const targetOffsetY = this.y - (canvas.height / PIXEL_SIZE / 2);
// Smoothly move the camera to the target position
worldOffsetX += (targetOffsetX - worldOffsetX) * 0.1;
worldOffsetY += (targetOffsetY - worldOffsetY) * 0.1;
// Smoothly move the camera to the target position (reduced smoothing factor)
worldOffsetX += (targetOffsetX - worldOffsetX) * 0.05;
worldOffsetY += (targetOffsetY - worldOffsetY) * 0.05;
// Mark that the world has moved for rendering
worldMoved = true;