Fix pause to freeze physics and stop extra runner loops

This commit is contained in:
Daddy32
2025-12-12 13:09:27 +01:00
parent 6fc2cbbb59
commit f482cafb2f

14
main.js
View File

@@ -24,11 +24,11 @@
id: "scene1",
name: "Balanced (default)",
config: {
gravity: 1,
spawnIntervalMs: 520,
gravity: 0.78,
spawnIntervalMs: 720,
minChain: 3,
palette: ["#ff595e", "#ffca3a", "#8ac926", "#1982c4", "#6a4c93"],
ballRadius: 18,
ballRadius: 38,
},
createBodies: (w, h) => [
Bodies.rectangle(w / 2, h + 40, w, 80, {
@@ -282,7 +282,7 @@
isPaused = false;
resetChainVisuals();
stopSpawner();
Runner.stop(runner);
engine.timing.timeScale = 0;
pauseOverlay.classList.remove("visible");
pauseBtn.textContent = "Pause";
finalScoreEl.textContent = score;
@@ -302,8 +302,8 @@
gameOverEl.classList.remove("visible");
pauseOverlay.classList.remove("visible");
pauseBtn.textContent = "Pause";
engine.timing.timeScale = 1;
updateHud();
Runner.run(runner, engine);
startSpawner();
};
@@ -321,10 +321,10 @@
if (isPaused) {
resetChainVisuals();
stopSpawner();
Runner.stop(runner);
engine.timing.timeScale = 0;
} else {
startSpawner();
Runner.run(runner, engine);
engine.timing.timeScale = 1;
}
};