Game state now contains a map of sounds to play next, for better perf

This commit is contained in:
Renan LE CARO 2025-03-17 19:47:16 +01:00
parent efa634cd8f
commit 581ee412d4
10 changed files with 1326 additions and 1153 deletions

View file

@ -8,7 +8,7 @@ import {
RunParams,
Upgrade,
} from "./types";
import { getAudioContext } from "./sounds";
import {getAudioContext, playPendingSounds} from "./sounds";
import {
currentLevelInfo,
getRowColIndex,
@ -429,7 +429,6 @@ export function bordersHitCheck(
return hhit + vhit * 2;
}
export function tick() {
const currentTick = performance.now();
const timeDeltaMs = currentTick - gameState.lastTick;
@ -458,6 +457,9 @@ export function tick() {
if (gameState.running) {
recordOneFrame(gameState);
}
if(isOptionOn('sound') ){
playPendingSounds(gameState)
}
requestAnimationFrame(tick);
}