reset fonctionnel

This commit is contained in:
Bocquel Raphael 2025-01-01 15:35:37 +01:00
parent 775462025f
commit db33d3337b
2 changed files with 14 additions and 8 deletions

View file

@ -36,7 +36,7 @@
</div>
<!-- <button id="debut_game" class="game_button" onclick="chrono()">GO!</button>-->
<button id="fin_game" class="game_button" onclick="reset()">CIAO</button>
<button id="fin_game" class="game_button" onclick="reset()">RESET</button>
<div id="popup" class="popup">
<div class="popup-content">

View file

@ -18,6 +18,10 @@ let number_mines = 10 ;
let first_click = true ;
function getRandomInt(maxi) {
return Math.floor(Math.random() * maxi);
}
function jeuFini() {
for (let i = 0; i < hauteur; i++) {
for (let j = 0; j < largeur; j++) {
@ -60,12 +64,12 @@ function creerGrille(haut, larg, mine_nb, x_first, y_first) {
}
for (var k = 0; k < mine_nb; k++) {
let new_x = Math.floor(Math.random() * larg);
let new_y = Math.floor(Math.random() * haut);
let new_x = getRandomInt(larg);
let new_y = getRandomInt(haut);
while (grille[new_y][new_x] == 9 || (new_y == y_first && new_x == x_first)) {
new_x = Math.floor(Math.random() * larg);
new_y = Math.floor(Math.random() * haut);
new_x = getRandomInt(larg);
new_y = getRandomInt(haut);
}
grille[new_y][new_x] = 9;
@ -206,11 +210,14 @@ function resetJeu(mouseEvent) {
divJeu.removeChild(divJeu.children[0]) ;
mouseEvent.target.removeEventListener("click",resetJeu) ;
grilleButtons(hauteur, largeur) ;
first_click = true ;
}
function changeImageClick(mouseEvent) {
changeImage(mouseEvent.target) ;
if (!(mouseEvent.target.classList.contains("buttonRevealed"))) {
changeImage(mouseEvent.target) ;
}
}
@ -257,8 +264,7 @@ function grilleButtons(haut, larg) {
divGrille.appendChild(newCase) ;
}
}
}
}
grilleButtons(hauteur,largeur) ;