reiniciarJuego() { | |
let memorama = []; | |
this.imagenes.forEach((imagen, indice) => { | |
let imagenDeMemorama = { | |
ruta: imagen, | |
mostrar: false, // No se muestra la original | |
acertada: false, // No es acertada al inicio | |
}; | |
// Poner dos veces la misma imagen | |
memorama.push(imagenDeMemorama, Object.assign({}, imagenDeMemorama)); | |
}); | |
// Sacudir o mover arreglo; es decir, hacerlo aleatorio | |
this.mezclarArreglo(memorama); | |
// Dividirlo en subarreglos o columnas | |
let memoramaDividido = []; | |
for (let i = 0; i < memorama.length; i += COLUMNAS) { | |
memoramaDividido.push(memorama.slice(i, i + COLUMNAS)); | |
} | |
// Reiniciar intentos | |
this.intentos = 0; | |
this.aciertos = 0; | |
// Asignar a instancia de Vue para que lo dibuje | |
this.memorama = memoramaDividido; | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment