This commit is contained in:
2026-08-07 23:35:25 -05:00
parent adb9390e89
commit 223e67c6b8
+20 -16
View File
@@ -152,14 +152,14 @@
overflow: hidden; overflow: hidden;
} }
body { body {
padding: .5rem .25rem; padding: 1rem .5rem;
max-height: 80vh; max-height: 80vh;
} }
#target-frame { #target-frame {
width: 90%; width: 90%;
} }
#text-frame { #text-frame {
margin-top: 1.25rem; margin-top: 3rem;
} }
#game-modes { #game-modes {
gap: .5rem; gap: .5rem;
@@ -265,6 +265,7 @@
let highScore = 0; let highScore = 0;
let targetsClicked = 0; let targetsClicked = 0;
let numTargets = 0; let numTargets = 0;
let preRoundText = "hold still on the circle, then click targets as fast as possible!";
// "NORMAL" MODE ONLY VARIABLES // "NORMAL" MODE ONLY VARIABLES
let currentRound = 0; let currentRound = 0;
@@ -460,7 +461,7 @@
} }
// set game instruction text + fade it in // set game instruction text + fade it in
gameText.innerText = "hover on red circle to start the countdown, then click the targets as fast as possible!"; gameText.innerText = preRoundText;
gameText.style.opacity = "0"; gameText.style.opacity = "0";
gameText.style.display = "inline"; gameText.style.display = "inline";
await sleep(500); await sleep(500);
@@ -591,7 +592,7 @@
} }
// set game instruction text + fade it in // set game instruction text + fade it in
gameText.innerText = "hover on red circle to start the countdown, then click as many targets as possible!"; gameText.innerText = preRoundText;
gameText.style.opacity = "0"; gameText.style.opacity = "0";
gameText.style.display = "inline"; gameText.style.display = "inline";
await sleep(500); await sleep(500);
@@ -701,43 +702,47 @@
/** HELPER TO KICK-OFF COUNTDOWNS FROM HOVER */ /** HELPER TO KICK-OFF COUNTDOWNS FROM HOVER */
// this prevents countdown from continuing if user removes / reapplies hover while we're sleeping
function cancelCountdown(hoverNumber) {
return !hovering || (hoverNumber != hoverCount);
}
async function drawCountdown(hoverNumber) { async function drawCountdown(hoverNumber) {
gameText.style.display = "none"; gameText.style.display = "none";
countingDown = true; countingDown = true;
// this if-check prevents countdown from continuing if user removes / reapplies hover while we're sleeping if (cancelCountdown(hoverNumber)) return false;
if (!hovering || hoverNumber != hoverCount) return false;
ready.style.display = "inline"; ready.style.display = "inline";
ready.style.opacity = "100"; ready.style.opacity = "100";
await sleep(1000); await sleep(1000);
if (!hovering || hoverNumber != hoverCount) return false; if (cancelCountdown(hoverNumber)) return false;
ready.style.display = "none"; ready.style.display = "none";
ready.style.opacity = "0"; ready.style.opacity = "0";
if (!hovering || hoverNumber != hoverCount) return false; if (cancelCountdown(hoverNumber)) return false;
one.style.opacity = "0"; one.style.opacity = "0";
two.style.opacity = "0"; two.style.opacity = "0";
three.style.opacity = "0"; three.style.opacity = "0";
if (!hovering || hoverNumber != hoverCount) return false; if (cancelCountdown(hoverNumber)) return false;
one.style.display = "inline"; one.style.display = "inline";
two.style.display = "inline"; two.style.display = "inline";
three.style.display = "inline"; three.style.display = "inline";
if (!hovering || hoverNumber != hoverCount) return false; if (cancelCountdown(hoverNumber)) return false;
three.style.opacity = "100"; three.style.opacity = "100";
await sleep(500); await sleep(500);
if (!hovering || hoverNumber != hoverCount) return false; if (cancelCountdown(hoverNumber)) return false;
two.style.opacity = "100"; two.style.opacity = "100";
await sleep(500); await sleep(500);
if (!hovering || hoverNumber != hoverCount) return false; if (cancelCountdown(hoverNumber)) return false;
one.style.opacity = "100"; one.style.opacity = "100";
await sleep(500); await sleep(500);
if (!hovering || hoverNumber != hoverCount) return false; if (cancelCountdown(hoverNumber)) return false;
one.style.display = "none"; one.style.display = "none";
two.style.display = "none"; two.style.display = "none";
three.style.display = "none"; three.style.display = "none";
@@ -755,7 +760,6 @@
return true; return true;
} }
function handleHoverEnd(e) { function handleHoverEnd(e) {
hovering = false; hovering = false;
@@ -775,7 +779,7 @@
if (gamemode == "normal") { if (gamemode == "normal") {
if (currentRound == 1) { if (currentRound == 1) {
gameText.innerText = "hover on red circle to start the countdown, then click the targets as fast as possible!"; gameText.innerText = preRoundText;
} }
else { else {
gameText.innerText = "ROUND: " + roundSeconds.toFixed(3) + "s\nTOTAL: " + totalTime.toFixed(3) + "s\nhover on circle to start round " + currentRound; gameText.innerText = "ROUND: " + roundSeconds.toFixed(3) + "s\nTOTAL: " + totalTime.toFixed(3) + "s\nhover on circle to start round " + currentRound;
@@ -783,7 +787,7 @@
} }
else if (gamemode == "countdown") { else if (gamemode == "countdown") {
gameText.innerText = "hover on red circle to start the countdown, then click as many targets as possible!"; gameText.innerText = preRoundText;
} }
gameText.style.display = "inline"; gameText.style.display = "inline";