fix: outward pawn hop animation on bottom row

- Track `fromSpace` before incrementing position for arc direction logic
- Flip Bézier control point for spaces 20–29 so pawns hop outward (away from center)
- Fixes awkward inward arc that made pieces clip through the board on the bottom edge
This commit is contained in:
Brian Fertig 2026-06-07 14:52:07 -06:00
parent ec3ae78570
commit 77e334e192
1 changed files with 7 additions and 3 deletions

View File

@ -1191,6 +1191,7 @@ export default class MonopolyGame extends Phaser.Scene {
const hopOne = () => { const hopOne = () => {
if (step >= steps) { resolve(); return; } if (step >= steps) { resolve(); return; }
step++; step++;
const fromSpace = cur;
cur = (cur + 1) % 40; cur = (cur + 1) % 40;
const start = { x: pawn.x, y: pawn.y }; const start = { x: pawn.x, y: pawn.y };
@ -1204,10 +1205,13 @@ export default class MonopolyGame extends Phaser.Scene {
const dx = BOARD_CX - mx; const dx = BOARD_CX - mx;
const dy = BOARD_CY - my; const dy = BOARD_CY - my;
const dist = Math.hypot(dx, dy); const dist = Math.hypot(dx, dy);
const nx = dist > 0 ? dx / dist : 0; let nx = dist > 0 ? dx / dist : 0;
const ny = dist > 0 ? dy / dist : -1; let ny = dist > 0 ? dy / dist : -1;
// Quadratic Bézier control point: ARCH_H px toward board center from midpoint // Top row (spaces 2029): arch away from center so the piece hops outward
if (fromSpace >= 20 && fromSpace <= 29) { nx = -nx; ny = -ny; }
// Quadratic Bézier control point: ARCH_H px toward/away from board center
const ctrl = { x: mx + nx * ARCH_H, y: my + ny * ARCH_H }; const ctrl = { x: mx + nx * ARCH_H, y: my + ny * ARCH_H };
const proxy = { t: 0 }; const proxy = { t: 0 };