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 |
+11
-1
@@ -18,9 +18,10 @@ let preguntas = [];
|
|||||||
let indice = 0; // pregunta que se está mostrando
|
let indice = 0; // pregunta que se está mostrando
|
||||||
let bloqueado = false; // true mientras se envía una respuesta o se ve el feedback
|
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 numeroAciertos = 0; // número de aciertos del jugador
|
||||||
|
let tiempoRespuesta = 0;
|
||||||
|
let intervaloTiempo;
|
||||||
|
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
|
|
||||||
// Obtenemos el idPartida de la URL
|
// Obtenemos el idPartida de la URL
|
||||||
// Ejemplo: juego.php?idPartida=3
|
// Ejemplo: juego.php?idPartida=3
|
||||||
|
|
||||||
@@ -83,6 +84,11 @@ function cargarPreguntas() {
|
|||||||
function mostrarPregunta() {
|
function mostrarPregunta() {
|
||||||
const pregunta = preguntas[indice];
|
const pregunta = preguntas[indice];
|
||||||
|
|
||||||
|
tiempoRespuesta = 0;
|
||||||
|
intervaloTiempo = setInterval(function () {
|
||||||
|
tiempoRespuesta++;
|
||||||
|
}, 100);
|
||||||
|
|
||||||
bloqueado = false;
|
bloqueado = false;
|
||||||
|
|
||||||
$("#textoPregunta").text(pregunta.nombrePregunta);
|
$("#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
|
// 3. El usuario pulsa una respuesta: se guarda y se enseña si ha acertado
|
||||||
function responder($botonPulsado) {
|
function responder($botonPulsado) {
|
||||||
|
clearInterval(intervaloTiempo);
|
||||||
|
console.log("Tiempo de respuesta: " + tiempoRespuesta / 10 + " segundos");
|
||||||
|
|
||||||
if (bloqueado) {
|
if (bloqueado) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -131,6 +140,7 @@ function responder($botonPulsado) {
|
|||||||
idPartida: idPartida,
|
idPartida: idPartida,
|
||||||
idPartidaxPregunta: pregunta.idPartidaxPregunta,
|
idPartidaxPregunta: pregunta.idPartidaxPregunta,
|
||||||
idRespuesta: idRespuesta,
|
idRespuesta: idRespuesta,
|
||||||
|
tiempoRespuesta: tiempoRespuesta,
|
||||||
},
|
},
|
||||||
success: function (datos) {
|
success: function (datos) {
|
||||||
if (datos.error) {
|
if (datos.error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user