fix: match object rotation to cell canvas rotation in dungeons
Two issues caused objects to float relative to dungeon map: 1. rotAngle used (heading + PI) but canvas uses (PI - heading) - these differ: sin(x+PI) = -sin(x) vs sin(PI-x) = sin(x) 2. Object dy was negated, but 180° heading offset already handles N/S - double N/S flip caused objects to drift with heading changes Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
6c500f7cdb
commit
8432c5f7c3
1 changed files with 5 additions and 3 deletions
|
|
@ -3969,8 +3969,8 @@ function updateRadarWindow(msg) {
|
|||
ctx.stroke();
|
||||
|
||||
// Rotate world by heading so player facing = up on canvas
|
||||
// In dungeons, add 180° to match UB's (heading - 180) rotation
|
||||
const rotAngle = isDungeon ? headingRad + Math.PI : headingRad;
|
||||
// In dungeons, use (PI - heading) to match UB's canvas rotation
|
||||
const rotAngle = isDungeon ? (Math.PI - headingRad) : headingRad;
|
||||
|
||||
// Draw objects and cache positions for click hit-testing
|
||||
const cosA = Math.cos(rotAngle);
|
||||
|
|
@ -3987,7 +3987,9 @@ function updateRadarWindow(msg) {
|
|||
}
|
||||
|
||||
const dx = dX * cosA - dY * sinA;
|
||||
const dy = -(dX * sinA + dY * cosA);
|
||||
// In dungeons, don't negate dy (180° heading offset handles N/S)
|
||||
// In overworld, negate for north-up
|
||||
const dy = isDungeon ? (dX * sinA + dY * cosA) : -(dX * sinA + dY * cosA);
|
||||
|
||||
const px = cx + dx * scale;
|
||||
const py = cy + dy * scale;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue