diff --git a/webapp/src/components/Game.js b/webapp/src/components/Game.js index 1ab644f6..f494ff54 100644 --- a/webapp/src/components/Game.js +++ b/webapp/src/components/Game.js @@ -35,11 +35,14 @@ const Game = () => { const [gameCorrectOptions, setGameCorrectOptions] = useState([]); const [gameQuestions, setGameQuestions] = useState([]); - // Temporizador const [seconds, setSeconds] = useState(120); + + + // Temporizador desde 20 segundos const [time, setTime] = useState(20); + const [isTimedOut, setTimedOut] = useState(false); // Estado para controlar si el temporizador está activo o no const [isTimerActive, setIsTimerActive] = useState(true); @@ -51,7 +54,8 @@ const Game = () => { if (prev > 0) { return prev - 1; } else { - return 20; // Reiniciar el tiempo a 20 segundos cuando llega a 0 + // Se acabó el tiempo + setTimedOut(true); } }); } @@ -316,9 +320,23 @@ const getQuestions = () => { + )} + {isTimedOut && ( +
¡Tiempo agotado!
+ + + incrementIncorrect(); + incrementQuestion(); + + restartTimer(); + +