From 3857c0de79438358e4959d2eba5a844f4a3199f5 Mon Sep 17 00:00:00 2001 From: Erik Date: Wed, 8 Apr 2026 15:31:23 +0200 Subject: [PATCH] fix: mirror X axis for dungeon tiles to match UB coordinate system UB uses mirrored X: x = -(cell.X - playerX), direct Y: y = cell.Y - playerY. Applied same transform to tile rendering, object positioning, and entity list distance calculations in dungeon mode. Co-Authored-By: Claude Opus 4.6 (1M context) --- static/script.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/static/script.js b/static/script.js index 2a8246c9..b27e09a8 100644 --- a/static/script.js +++ b/static/script.js @@ -3877,12 +3877,13 @@ function updateRadarWindow(msg) { ctx.globalAlpha = isCurrentFloor ? 0.85 : 0.12; (level.cells || []).forEach(cell => { - const dx = (cell.x - playerX) * scale; - const dy = -(cell.y - playerY) * scale; // Y flipped + // UB mirrors X: x = -(cell.x - playerX), Y is direct: y = cell.y - playerY + const dx = -(cell.x - playerX) * scale; + const dy = (cell.y - playerY) * scale; const tileCanvas = hasTiles ? dungeonTileCanvases[String(cell.env_id)] : null; if (tileCanvas) { - // Draw processed tile with rotation + // Draw processed tile with per-cell rotation ctx.save(); ctx.translate(dx, dy); ctx.rotate(cellRotation(cell.rotation)); @@ -3972,11 +3973,11 @@ function updateRadarWindow(msg) { const cosA = Math.cos(rotAngle); const sinA = Math.sin(rotAngle); objects.forEach(obj => { - // Use raw physics coords in dungeons, EW/NS on surface + // Use raw physics coords in dungeons (X mirrored), EW/NS on surface let dX, dY; if (isDungeon && obj.raw_x !== undefined) { - dX = obj.raw_x - playerX; - dY = obj.raw_y - playerY; + dX = -(obj.raw_x - playerX); // X mirrored to match UB coordinate system + dY = (obj.raw_y - playerY); } else { dX = obj.ew - playerEW; dY = obj.ns - playerNS; @@ -4038,8 +4039,8 @@ function updateRadarWindow(msg) { const withDist = objects.map(obj => { let distMeters, dX, dY; if (isDungeon && obj.raw_x !== undefined) { - dX = obj.raw_x - playerX; - dY = obj.raw_y - playerY; + dX = -(obj.raw_x - playerX); // X mirrored + dY = (obj.raw_y - playerY); distMeters = Math.sqrt(dX * dX + dY * dY); // raw coords are ~meters } else { dX = obj.ew - playerEW;