diff --git a/src/main.js b/src/main.js index 445ff3e..cbb4964 100644 --- a/src/main.js +++ b/src/main.js @@ -10,6 +10,9 @@ const GROUND_ART_SURFACE_OFFSET = 20; const LOG_FRAME_HEIGHT = 79; const LOG_ART_SURFACE_OFFSET = 17; const LOG_COLLIDER_HEIGHT = 16; +const LOG_SURFACE_LEFT = 15; +const LOG_SURFACE_RIGHT = 266; +const LOG_FRAME_WIDTH = 269; class ForestScene extends Phaser.Scene { constructor() { @@ -121,6 +124,9 @@ class ForestScene extends Phaser.Scene { addFrame('terrain-sheet', 'ground-main', 24, 32, 341, 107); + // Interior-only repeat crop: removes the standalone tile's visible + // left/right border so adjacent ground pieces join cleanly. + addFrame('terrain-sheet', 'ground-repeat', 52, 32, 285, 107); addFrame('terrain-sheet', 'log-platform', 21, 327, 269, 79); addFrame('terrain-sheet', 'root-platform', 1023, 672, 402, 168); @@ -385,8 +391,10 @@ class ForestScene extends Phaser.Scene { this.platforms.add(ground); const groundArtY = GROUND_SURFACE_Y - (GROUND_ART_SURFACE_OFFSET * GROUND_ART_SCALE); - for (let x = 165; x < WORLD_WIDTH + 340; x += 320) { - this.add.image(x, groundArtY, 'terrain-sheet', 'ground-main') + const groundTileWidth = 285 * GROUND_ART_SCALE; + const groundTileStep = groundTileWidth - 3; // tiny overlap avoids antialias hairlines + for (let x = groundTileWidth / 2; x < WORLD_WIDTH + groundTileWidth; x += groundTileStep) { + this.add.image(x, groundArtY, 'terrain-sheet', 'ground-repeat') .setOrigin(0.5, 0) .setScale(GROUND_ART_SCALE) .setDepth(3); @@ -413,10 +421,15 @@ class ForestScene extends Phaser.Scene { .setScale(scale) .setDepth(6); + const surfaceWidth = (LOG_SURFACE_RIGHT - LOG_SURFACE_LEFT) * scale; + const surfaceCenterOffset = ( + ((LOG_SURFACE_LEFT + LOG_SURFACE_RIGHT) / 2) - (LOG_FRAME_WIDTH / 2) + ) * scale; + const collider = this.add.rectangle( - x, + x + surfaceCenterOffset, surfaceY + (LOG_COLLIDER_HEIGHT / 2), - Math.max(130, visual.displayWidth * 0.82), + surfaceWidth, LOG_COLLIDER_HEIGHT, 0x000000, 0