From aba87e9cb3be1cf640d1950627ff835f0f483c2c Mon Sep 17 00:00:00 2001 From: Admin Date: Sat, 19 Sep 2026 08:02:08 +0000 Subject: [PATCH] fix: sync log platform art collision alignment --- src/main.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/main.js b/src/main.js index 7df43d6..445ff3e 100644 --- a/src/main.js +++ b/src/main.js @@ -7,6 +7,9 @@ const GROUND_Y = 628; const GROUND_SURFACE_Y = GROUND_Y - 4; const GROUND_ART_SCALE = 0.98; const GROUND_ART_SURFACE_OFFSET = 20; +const LOG_FRAME_HEIGHT = 79; +const LOG_ART_SURFACE_OFFSET = 17; +const LOG_COLLIDER_HEIGHT = 16; class ForestScene extends Phaser.Scene { constructor() { @@ -398,17 +401,23 @@ class ForestScene extends Phaser.Scene { [4680, 545], [4890, 505], [5100, 465] ]; - branchPositions.forEach(([x, y], index) => { + // branchPositions store the intended walkable surface Y, not the + // collider centre. The illustrated log's usable top edge is 17 source + // pixels below its cropped frame top, so derive art + physics from the + // same surface coordinate. + branchPositions.forEach(([x, surfaceY], index) => { const scale = index % 3 === 0 ? 0.62 : 0.55; - const visual = this.add.image(x, y + 15, 'terrain-sheet', 'log-platform') + const visualY = surfaceY + ((LOG_FRAME_HEIGHT / 2 - LOG_ART_SURFACE_OFFSET) * scale); + + const visual = this.add.image(x, visualY, 'terrain-sheet', 'log-platform') .setScale(scale) .setDepth(6); const collider = this.add.rectangle( x, - y, + surfaceY + (LOG_COLLIDER_HEIGHT / 2), Math.max(130, visual.displayWidth * 0.82), - 16, + LOG_COLLIDER_HEIGHT, 0x000000, 0 );