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:
parent
ec3ae78570
commit
77e334e192
|
|
@ -1191,6 +1191,7 @@ export default class MonopolyGame extends Phaser.Scene {
|
|||
const hopOne = () => {
|
||||
if (step >= steps) { resolve(); return; }
|
||||
step++;
|
||||
const fromSpace = cur;
|
||||
cur = (cur + 1) % 40;
|
||||
|
||||
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 dy = BOARD_CY - my;
|
||||
const dist = Math.hypot(dx, dy);
|
||||
const nx = dist > 0 ? dx / dist : 0;
|
||||
const ny = dist > 0 ? dy / dist : -1;
|
||||
let nx = dist > 0 ? dx / dist : 0;
|
||||
let ny = dist > 0 ? dy / dist : -1;
|
||||
|
||||
// Quadratic Bézier control point: ARCH_H px toward board center from midpoint
|
||||
// Top row (spaces 20–29): 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 proxy = { t: 0 };
|
||||
|
|
|
|||
Loading…
Reference in New Issue