Created
August 7, 2019 02:42
-
-
Save parzibyte/bff9f59d5ae126f883714a1493953f8a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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