Fix end-of-world portal flow to allow forward-only progression
This commit is contained in:
parent
52717f67a9
commit
50671b483f
14
js/game.js
14
js/game.js
@ -176,7 +176,9 @@ function createInitialState(config = gameConfig) {
|
|||||||
portal: {
|
portal: {
|
||||||
active: false,
|
active: false,
|
||||||
entered: false,
|
entered: false,
|
||||||
x: worldWidth - 180,
|
// Keep portal close to the world edge so forward motion naturally carries
|
||||||
|
// the player into it once progression is unlocked.
|
||||||
|
x: worldWidth - 60,
|
||||||
width: 52,
|
width: 52,
|
||||||
height: 92,
|
height: 92,
|
||||||
y: groundY - 92,
|
y: groundY - 92,
|
||||||
@ -521,11 +523,15 @@ function updatePortal(dt) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const p = state.player;
|
const p = state.player;
|
||||||
const atWorldEnd = p.x >= worldWidth - p.width - 8;
|
const worldEndX = worldWidth - p.width - 8;
|
||||||
|
// Activate slightly before the hard clamp at world end so the player can
|
||||||
|
// continue moving right and enter the portal without reversing direction.
|
||||||
|
const portalActivationX = Math.max(0, state.portal.x - p.width - 24);
|
||||||
|
const reachedProgressionPoint = p.x >= portalActivationX;
|
||||||
|
|
||||||
if (atWorldEnd) {
|
if (reachedProgressionPoint) {
|
||||||
state.portal.active = true;
|
state.portal.active = true;
|
||||||
state.worldCleared = true;
|
state.worldCleared = p.x >= worldEndX;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!state.portal.active || state.portal.entered) return;
|
if (!state.portal.active || state.portal.entered) return;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user