From a8747275af041bf4f807a719b3196102de29e289 Mon Sep 17 00:00:00 2001 From: Atlaskor Date: Thu, 13 Nov 2025 17:59:13 +0000 Subject: [PATCH] Update server/static/map.js --- server/static/map.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/server/static/map.js b/server/static/map.js index bb09ccc..8ed6207 100644 --- a/server/static/map.js +++ b/server/static/map.js @@ -167,11 +167,14 @@ export class MapView { const seen = new Set(); for (const p of players) { seen.add(p.id); - const snapped = this.snapToTile(p.x, p.y); + + // If you're using tiles: + const pos = this.snapToTile ? this.snapToTile(p.x, p.y) : { x: p.x, y: p.y }; + if (!this.otherSprites.has(p.id)) { - const img = this.scene.add.image(snapped.x, snapped.y, 'other').setDepth(5); + const img = this.scene.add.image(pos.x, pos.y, 'other').setDepth(5); const label = this.scene - .add.text(snapped.x, snapped.y - 22, p.name || 'Player', { + .add.text(pos.x, pos.y - 22, p.name || 'Player', { fontSize: '12px', color: '#9ca3af' }) @@ -179,11 +182,12 @@ export class MapView { this.otherSprites.set(p.id, { img, label }); } else { const rec = this.otherSprites.get(p.id); - rec.img.setPosition(snapped.x, snapped.y); - rec.label.setPosition(snapped.x, snapped.y - 22); + rec.img.setPosition(pos.x, pos.y); + rec.label.setPosition(pos.x, pos.y - 22); } } - // Remove any that disappeared + + // Clean up players that disconnected for (const [id, rec] of this.otherSprites) { if (!seen.has(id)) { rec.img.destroy();