fix: sync platform side bounds and seamless ground
This commit is contained in:
parent
aba87e9cb3
commit
b857ae5f2b
21
src/main.js
21
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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user