Re-introduced power saving mode

This commit is contained in:
Renan LE CARO 2025-03-16 20:11:08 +01:00
parent 9bf7e9534d
commit bdfe5408b9
6 changed files with 3702 additions and 4 deletions

View file

@ -84,6 +84,7 @@ export function pause(playerAskedForPause: boolean) {
gameState.pauseTimeout = null;
document.body.className = gameState.running ? " running " : " paused ";
scoreDisplay.className = "";
gameState.needsRender=true
},
Math.min(Math.max(0, gameState.pauseUsesDuringRun - 5) * 50, 500),
);
@ -455,8 +456,13 @@ export function tick() {
gameState.runStatistics.runTime += timeDeltaMs;
gameStateTick(gameState, frames);
}
render(gameState);
recordOneFrame(gameState);
if(gameState.running || gameState.needsRender){
gameState.needsRender=false
render(gameState);
}
if(gameState.running){
recordOneFrame(gameState);
}
requestAnimationFrame(tick);
}
@ -684,6 +690,7 @@ async function openSettingsPanel() {
});
if (cb) {
cb();
gameState.needsRender=true
}
}