Skip to content

Commit

Permalink
✨ Pregunta incorrecta si pasa de tiempo
Browse files Browse the repository at this point in the history
  • Loading branch information
UO285240 committed Apr 7, 2024
1 parent 838e093 commit 4983926
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions webapp/src/components/Game.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
}
});
}
Expand Down Expand Up @@ -316,9 +320,23 @@ const getQuestions = () => {
</div>
</Typography>

)}

{isTimedOut && (
<div className="modal">
<div className="modal-content">
<p>¡Tiempo agotado!</p>
<button onClick={() => setTimedOut(false)}>Cerrar</button>

incrementIncorrect();
incrementQuestion();

restartTimer();

</div>
</div>
)}

)}


<Typography variant="body1" paragraph>
Expand Down

0 comments on commit 4983926

Please sign in to comment.