From df604e7e2603a087907a39b21f93eb4cee8c85b0 Mon Sep 17 00:00:00 2001 From: Pinapelz Date: Thu, 16 Apr 2026 21:05:47 -0700 Subject: type: auto detect intermission mid-song, grace period between lines --- src/app/game/page.tsx | 157 ++++++++++++++++++++++++++++---------------------- 1 file changed, 87 insertions(+), 70 deletions(-) (limited to 'src/app') diff --git a/src/app/game/page.tsx b/src/app/game/page.tsx index f43b3c4..fa5f6b1 100644 --- a/src/app/game/page.tsx +++ b/src/app/game/page.tsx @@ -94,6 +94,7 @@ function GameInner() { const videoRef = useRef(null); const gameStartTimeRef = useRef(0); const lastHandledIdxRef = useRef(-1); + const lastLineAdvanceAtRef = useRef(0); const [phase, setPhase] = useState("idle"); const [currentMs, setCurrentMs] = useState(0); @@ -347,6 +348,7 @@ function GameInner() { if (timeBasedLineIdx < 0) return; if (timeBasedLineIdx <= lastHandledIdxRef.current) return; lastHandledIdxRef.current = timeBasedLineIdx; + lastLineAdvanceAtRef.current = performance.now(); dispatch({ type: "ADVANCE", newIdx: timeBasedLineIdx, @@ -474,6 +476,7 @@ function GameInner() { setComboAnimKey((k) => k + 1); } } else { + if (performance.now() - lastLineAdvanceAtRef.current < 100) return; dispatch({ type: "WRONG" }); setWrongChar(true); setTimeout(() => setWrongChar(false), 320); @@ -497,15 +500,6 @@ function GameInner() { return ( - {isVideo && ( - - )} {!isVideo && (