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: {
|
||||
active: 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,
|
||||
height: 92,
|
||||
y: groundY - 92,
|
||||
@ -521,11 +523,15 @@ function updatePortal(dt) {
|
||||
}
|
||||
|
||||
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.worldCleared = true;
|
||||
state.worldCleared = p.x >= worldEndX;
|
||||
}
|
||||
|
||||
if (!state.portal.active || state.portal.entered) return;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user