Compare commits
18 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e9cf7c8fcf | |||
| 111a101037 | |||
| 71b7337dba | |||
| dc5c04b693 | |||
| 29eb70b626 | |||
| 5bf5b7a3bc | |||
| e8accf949e | |||
| fa883cde39 | |||
| ae213a3d12 | |||
| cd0685f41c | |||
| e3395a017c | |||
| 396aca8b03 | |||
| c6db380ef9 | |||
| 8d5d7da615 | |||
| 7f70112f63 | |||
| 71fb45b94c | |||
| 2531ef321a | |||
| 5446352cf9 |
+12
-2
@@ -18,9 +18,10 @@ let preguntas = [];
|
||||
let indice = 0; // pregunta que se está mostrando
|
||||
let bloqueado = false; // true mientras se envía una respuesta o se ve el feedback
|
||||
let numeroAciertos = 0; // número de aciertos del jugador
|
||||
let tiempoRespuesta = 0;
|
||||
let intervaloTiempo;
|
||||
|
||||
$(document).ready(function () {
|
||||
|
||||
// Obtenemos el idPartida de la URL
|
||||
// Ejemplo: juego.php?idPartida=3
|
||||
|
||||
@@ -83,6 +84,11 @@ function cargarPreguntas() {
|
||||
function mostrarPregunta() {
|
||||
const pregunta = preguntas[indice];
|
||||
|
||||
tiempoRespuesta = 0;
|
||||
intervaloTiempo = setInterval(function () {
|
||||
tiempoRespuesta++;
|
||||
}, 100);
|
||||
|
||||
bloqueado = false;
|
||||
|
||||
$("#textoPregunta").text(pregunta.nombrePregunta);
|
||||
@@ -111,6 +117,9 @@ function mostrarPregunta() {
|
||||
|
||||
// 3. El usuario pulsa una respuesta: se guarda y se enseña si ha acertado
|
||||
function responder($botonPulsado) {
|
||||
clearInterval(intervaloTiempo);
|
||||
console.log("Tiempo de respuesta: " + tiempoRespuesta / 10 + " segundos");
|
||||
|
||||
if (bloqueado) {
|
||||
return;
|
||||
}
|
||||
@@ -130,7 +139,8 @@ function responder($botonPulsado) {
|
||||
orden: "responder",
|
||||
idPartida: idPartida,
|
||||
idPartidaxPregunta: pregunta.idPartidaxPregunta,
|
||||
idRespuesta: idRespuesta,
|
||||
idRespuesta: idRespuesta,
|
||||
tiempoRespuesta: tiempoRespuesta,
|
||||
},
|
||||
success: function (datos) {
|
||||
if (datos.error) {
|
||||
|
||||
Reference in New Issue
Block a user