From d06610ca58ac8681c7ac136beb37017b4a3f71a9 Mon Sep 17 00:00:00 2001 From: Bocquel Raphael Date: Mon, 23 Dec 2024 15:47:19 +0100 Subject: [PATCH 01/15] grille marche mieux --- case_flag.png | Bin 0 -> 308 bytes case_zero.png | Bin 0 -> 263 bytes demineur.html | 2 ++ demineur.js | 34 ++++++++++++++++++++++++++++------ style.css | 4 ++-- 5 files changed, 32 insertions(+), 8 deletions(-) create mode 100644 case_flag.png create mode 100644 case_zero.png diff --git a/case_flag.png b/case_flag.png new file mode 100644 index 0000000000000000000000000000000000000000..0267f6783651dc1c8397b0d2954931cbc1f6909a GIT binary patch literal 308 zcmV-40n7f0P)0n z5Kxdc1PmmFfPmy6%tLY!rXgDpW+7VkMYy)2}!g;u|HN! zBy%8{NM@mae#T+vuuFROzru&>-%vISF`FPC(;=0UmG?} zRARDOtF)m=$1SDAwOK-wN&9$`i(9x!$3(c`q={woU)#BsPfA*bP0l+XkK DJ+f$L literal 0 HcmV?d00001 diff --git a/demineur.html b/demineur.html index c79f818..fdd4027 100644 --- a/demineur.html +++ b/demineur.html @@ -33,8 +33,10 @@
+
+
diff --git a/demineur.js b/demineur.js index 3e1dbf1..0a5f99e 100644 --- a/demineur.js +++ b/demineur.js @@ -7,8 +7,8 @@ class Case { this.hidden = true; } - } + function sleep(ms){ return new Promise(resolve => setTimeout(resolve, ms)); } @@ -59,28 +59,50 @@ function creerGrille(haut, larg) { } +function selectImage(idCase) { + const coords = idCase.split("_") ; + const x = parseInt(coords[0]) ; + const y = parseInt(coords[0]) ; +} + + + function changeImage(mouseEvent) { - mouseEvent.target.style.background="url('case_mine.png')" ; + if (!(mouseEvent.target.classList.contains("buttonFlagged"))) { + mouseEvent.target.style.background="url('case_mine.png')" ; + mouseEvent.target.classList.add("buttonRevealed") ; + } } +function changeImageFlag(rightClick) { + + rightClick.preventDefault() ; + if (rightClick.target.classList.contains("buttonRevealed")) { + return 0 ; + } else if (rightClick.target.classList.contains("buttonFlagged")) { + rightClick.target.style.background="url('case_vide.png')" ; + rightClick.target.classList.remove("buttonFlagged") ; + } else { + rightClick.target.style.background="url('case_flag.png')" ; + rightClick.target.classList.add("buttonFlagged") ; + } +} + function grilleButtons(haut, larg) { const divGrille = document.getElementById("grille") ; for (var i=0;i Date: Wed, 25 Dec 2024 15:24:46 +0100 Subject: [PATCH 02/15] finalisation popup cookie --- demineur.js | 45 ++++++++++++++++++--------------------------- style.css | 23 +++++------------------ 2 files changed, 23 insertions(+), 45 deletions(-) diff --git a/demineur.js b/demineur.js index 89b184f..6cd433d 100644 --- a/demineur.js +++ b/demineur.js @@ -8,18 +8,6 @@ class Case { } } -<<<<<<< HEAD -======= -//Fonction pour créer un cookie. -function setCookie(name, value, days) { - const expires = new Date(Date.now() + days * 864e5).toUTCString(); - document.cookie = `${name}=${value}; expires=${expires}; path=/`; -} -// Fonction pour lire un cookie -function getCookie(name) { - return document.cookie.split('; ').find(row => row.startsWith(name + '='))?.split('=')[1]; -} ->>>>>>> d322df708ea3bd0301a054980adc49db1c96d181 function sleep(ms){ return new Promise(resolve => setTimeout(resolve, ms)); @@ -44,15 +32,7 @@ async function reset(){ } -function Cookies() { - var accept = confirm("Tu veux des cookies ?"); - if (accept === true) { - alert("Bon jeu!"); - } else { - Cookies(); - } - } -//Cookies(); + let grille = []; @@ -70,21 +50,32 @@ function creerGrille(haut, larg) { } +// Fonction pour créer un cookie +function setCookie(name, value, days) { + const expires = new Date(Date.now() + days * 864e5).toUTCString(); + document.cookie = `${name}=${value}; expires=${expires}; path=/`; +} +// Fonction pour lire un cookie +function getCookie(name) { + return document.cookie.split('; ').find(row => row.startsWith(name + '='))?.split('=')[1]; +} function cookie(){ const popup = document.getElementById('popup'); - const closePopupButton = document.getElementById('accept-button'); - + const close_popup_button = document.getElementById('accept-button'); + const keep_popup_button = document.getElementById('refuse-button'); // Fonction pour afficher la pop-up - popup.classList.add('show'); - + + keep_popup_button.addEventListener('click', () => { + keep_popup_button.style.display = 'none'; + }); // Fonction pour fermer la pop-up - closePopupButton.addEventListener('click', () => { - setCookie('cookiesAccepted', 'true', 1); // Stocke l'acceptation pendant 1 jour + close_popup_button.addEventListener('click', () => { + // setCookie('cookiesAccepted', 'true', 1); // Stocke l'acceptation pendant 1 jour popup.classList.remove('show'); }); diff --git a/style.css b/style.css index b64d1d2..680841c 100644 --- a/style.css +++ b/style.css @@ -38,7 +38,6 @@ padding-right: 10px; } -<<<<<<< HEAD .popup { position: fixed; top: 0; @@ -70,15 +69,7 @@ width: 100%; } -#accept-button { - background-color: #007BFF; - color: #fff; - border: none; - padding: 10px 20px; - border-radius: 5px; - cursor: pointer; -} -#refuse-button { +#accept-button, #refuse-button { background-color: #007BFF; color: #fff; border: none; @@ -87,12 +78,8 @@ cursor: pointer; } -#close-popup:hover { - background-color: #0056b3; -======= -.button_case{ - width : 50px; - height : 50px; - border : 0px; ->>>>>>> 2a2cf84cf311b49f5c290c8502b43f35efa7ec30 + +#refuse-button:hover,#accept-button:hover { + background-color: #1ecfee; + } From 81d1e561e1080b67e2c407bffaf0f1b92b325502 Mon Sep 17 00:00:00 2001 From: "bezza@insa-toulouse.fr" Date: Wed, 25 Dec 2024 16:08:14 +0100 Subject: [PATCH 03/15] ajout des confettis en cas de victoire (script externe) --- demineur.html | 44 +++++++++++++++++++++++++++++++++++++++++--- demineur.js | 2 +- style.css | 3 ++- 3 files changed, 44 insertions(+), 5 deletions(-) diff --git a/demineur.html b/demineur.html index de68c9e..3eda214 100644 --- a/demineur.html +++ b/demineur.html @@ -31,15 +31,15 @@
- - +
- + + +
+ + + + + + + + + + + + +
diff --git a/demineur.js b/demineur.js index 6cd433d..26c64b5 100644 --- a/demineur.js +++ b/demineur.js @@ -75,7 +75,7 @@ function cookie(){ // Fonction pour fermer la pop-up close_popup_button.addEventListener('click', () => { - // setCookie('cookiesAccepted', 'true', 1); // Stocke l'acceptation pendant 1 jour + setCookie('cookiesAccepted', 'true', 1); // Stocke l'acceptation pendant 1 jour popup.classList.remove('show'); }); diff --git a/style.css b/style.css index 680841c..6f1c646 100644 --- a/style.css +++ b/style.css @@ -11,7 +11,7 @@ } #body_demineur{ - background-color: rgba(128, 128, 128, 0.544); + background-color: #007BFF; margin: 0; @@ -24,6 +24,7 @@ border-width: 2px; border-style: double; width: 49%; + background-color: #fff; } From a317d01247ea7384cf14fc2a1d7c00d74168ef25 Mon Sep 17 00:00:00 2001 From: Bocquel Raphael Date: Tue, 31 Dec 2024 17:37:58 +0100 Subject: [PATCH 04/15] fin base demineur --- case_0.png | Bin 0 -> 263 bytes case_1.png | Bin 0 -> 293 bytes case_2.png | Bin 0 -> 389 bytes case_3.png | Bin 0 -> 430 bytes case_4.png | Bin 0 -> 321 bytes case_5.png | Bin 0 -> 369 bytes case_6.png | Bin 0 -> 431 bytes case_7.png | Bin 0 -> 310 bytes case_8.png | Bin 0 -> 436 bytes case_9.png | Bin 0 -> 456 bytes demineur.html | 5 +-- demineur.js | 91 +++++++++++++++++++++++++++++++++++++------------- style.css | 17 ++++------ 13 files changed, 75 insertions(+), 38 deletions(-) create mode 100644 case_0.png create mode 100644 case_1.png create mode 100644 case_2.png create mode 100644 case_3.png create mode 100644 case_4.png create mode 100644 case_5.png create mode 100644 case_6.png create mode 100644 case_7.png create mode 100644 case_8.png create mode 100644 case_9.png diff --git a/case_0.png b/case_0.png new file mode 100644 index 0000000000000000000000000000000000000000..43d26289ef15cbccf0669fa78227ed23c77b1a1d GIT binary patch literal 263 zcmeAS@N?(olHy`uVBq!ia0vp^Mj*_=1|;R|J2nETbDl1aAsNnZXF2j6RuEu5efYu0 z8l7IPt*fpGZwp_MVUfPKqAfY<{og8?f?I{I&*s#>Ozru&>-%vISF`FPC(;=0UmG?} zRARDOtF)m=$1SDAwOK-wN&9$`i(9x!$3(c`q={woU)#BsPfA*bP0l+XkK DJ+f$L literal 0 HcmV?d00001 diff --git a/case_1.png b/case_1.png new file mode 100644 index 0000000000000000000000000000000000000000..ebb7475efe65fc9c202189b55661dc71fdd3049b GIT binary patch literal 293 zcmV+=0owkFP)(A?gIk^A{Foo?5z*bD`!0PhhNBWq2P1k&}B9S}tyY})-|1S3XoQAjOPi`3fA z0cwOAp+=~YCIYnauaI5uMhhc?JR`OEsw+qri%YvsEsG6l*91fx rIjeaXv5KsA-NuM^Ausa|^S{;;+_Xi`Wg`p100000NkvXXu0mjff)I0B literal 0 HcmV?d00001 diff --git a/case_2.png b/case_2.png new file mode 100644 index 0000000000000000000000000000000000000000..ed29af6d4f952422d400e61e1d8c7a869dca8ec6 GIT binary patch literal 389 zcmV;00eb$4P)C zgnIU&)|C*c9g{@n-^HJ6`drk(Zq-o`rVuTlv?iAAQ_@KF>@|W&1et_*`_-mFL8KJ8 zkFO|^jNx`hMMx$~1zC2OQCm1mgm{f`XUrPm0`WkYLc9Q`yOuY?B#{UN91?|qLLw0` zNHhWhp&+>Lopn9s;HY}Ddmzk@@m>g1h$q4f;*DsK_IX;n$13kvZNJLCp|>{(bUFcz j)td-lazdM^=Kor6r_^T7B148A00000NkvXXu0mjfp`f23 literal 0 HcmV?d00001 diff --git a/case_3.png b/case_3.png new file mode 100644 index 0000000000000000000000000000000000000000..aaabc73ed4f451253bb7f027a2deb23ebf4b821a GIT binary patch literal 430 zcmV;f0a5;mP)E0_KSOrBPnBo64*fd+(q+ebSp~|YR>+X`lQ)LIzw(Vbf zX`1FU@5x93+1X<;va^7%^u>r|=|D7VTU!(DnD40ZB1kAj3q~5=+UX>-!gs z6x$6VP0IQnff#Zf0tAIP1PBAd4N~<_*FV|RA+9RkDril^C z1%evUfLMzKfmoBx3!s6q6bu5HC-OisVQ3(h>P46-AYKF3hEeLVc0IKsV4$VN?tqca z?*c);9jr!%@zN3t0kO0iQc<+ALP3}ZLWmKm>0<(DmKD_fYL^59O0ofgq_U!cfI-G; zN7&H39-g8%>k literal 0 HcmV?d00001 diff --git a/case_4.png b/case_4.png new file mode 100644 index 0000000000000000000000000000000000000000..3907567249ba287145eb9d088a07075ce65a330b GIT binary patch literal 321 zcmV-H0lxl;P)R*>~noIvJG;X(Nda_pJkRfY3zNMjP^q- zRPv`*G}1{RMynA{jF!fpiP4JD(wL)@*D&4enzn#wrm3;kx{YY0W4XpM|JQl}Qo=wG TdIjj900000NkvXXu0mjfW}<`l literal 0 HcmV?d00001 diff --git a/case_5.png b/case_5.png new file mode 100644 index 0000000000000000000000000000000000000000..423b1e4017109c9e22bb92fc286c6d915fd42926 GIT binary patch literal 369 zcmV-%0gnEOP)H6P9?&r(!+MjOM)ivov60%y;o(T z6NF++A;>+#rWY0>Ne{scPek&t2oGr}q}39F99pX}he!lLpf^2z*yoEQy}OhgiWma< z+#~{H04So3Qzc?`PI~ho#R(5V5uqUrA}oYOgoH>C;UH3k2!g&Ju}?G&LJX0-!Ty42 zH$R_~zDIhMMlL(c&AUO^cCs9Anuz7b*trtIR?K_+S0dgEde48D|7$$};k7gn!XcOd P00000NkvXXu0mjfAAg*` literal 0 HcmV?d00001 diff --git a/case_6.png b/case_6.png new file mode 100644 index 0000000000000000000000000000000000000000..698011590133ad9d0fa9a307fef12819f96a3534 GIT binary patch literal 431 zcmV;g0Z{&lP)v_`i5M$S@o; zm>9<_Lii@qA;9i>UT;5FT^@JfF6@$OiOeUBOveIqhbVv)sbbt9R)7`LA@iC)MIt3c zuI`uaRrZNXY2_fwq>v6bzs3w{0r5G}Ehl>`h-#3n$|)@`IgysqFeS1E*&~e(8CT$M z5-A;$<6?N0VU^9U9B5WlGmr_df+Pr1HcBcMOp_30|1=9>F-=1l3=OHhKbH0u(g3PL z*bl0;2H_4t(?A|PP1>N{dt)yF=9OvX)9yi7Pn8_PDk~JXXnQrON;S002ovPDHLkV1jI5vbF#K literal 0 HcmV?d00001 diff --git a/case_7.png b/case_7.png new file mode 100644 index 0000000000000000000000000000000000000000..41c61dc764bb2d227a396583dc6e401546e415ff GIT binary patch literal 310 zcmeAS@N?(olHy`uVBq!ia0vp^Mj*_=1|;R|J2nETzn(6RAsNnZZ`tx4GT>oNc+T~v z=gxnJo;Q1)en?8JU^-NJ{`|_AmC1AJ>N-VSbJMQLzyIWKEwkjiX>;b=nXNaiCpLAI zhpQ^_C79Q$ZYoi_{Zr}hzsql}=KNp3G*lp63=%;!Tm%z_C;;;;c|ajZ z2Ev;iHzX6`!TdLb$;MK>N58*x^0_jCE@Z7~6)~ouGzfC?AQ&XhYgqIQjj9Ex;&jNk z1JT`#et+KZuF^sw=)k9#zub^)4BF&v6GD(I42y6#`?M60T4zgab4UilGiQY|l8NwO zTs^V{g2m8~EfEYR6`~j#M-0;Z6a>u%a^tq!s+e*JgJ3XLTq(r5+1m5O%8V7eLzZ^e z+O^$e1U+HqAgip9xYE*M&V8oQ4iLm`j=0000xJ(1d1VP-d3JQi?w-;C?%^yizyM^D#8=xaL6Cb^S?QmSuUz z{ZXWYd|Ah?h(-YC+;ALaCdWq==^%joYDF~JE!js6@}9Fv&zEeU1;WBGAWT~yM>a?b zW}2o;hi}^!eaAwWfy7|$0M5}%APs~mh=gGv0+ff*LYRa20q-F8eILegq^$(oKs+$yyNwKGt2tgnqS{M_MloF|I#@@5abP$=vCKN#-e0_xHZsw8+V(gV| zEd)eDFfdht#2`?ZA|QU%jXlyPA?Vm|mVINV%;MInPLZp%;BRU~uIgxQ$c-erm}XlG z-JYNUX&}sYzlgm$2$%sAYoYe4e)rqdc?5w;DZ;GeXUCaY%MTpR+?wLA=FEP+IACC^ zxkb6V{rH)CE#?ZRRNL$YkqJ!J5V$l@_gv~?XCX8oOdmA}npN3O1CM^EgP@seQV|V2 y+UHSgp+RZdbr4O~O7>}2k&;<^V(e!Auk`|^u*S}r&=7k70000GO! -
- - -
+ diff --git a/demineur.js b/demineur.js index 89b184f..dae1c66 100644 --- a/demineur.js +++ b/demineur.js @@ -1,4 +1,4 @@ -class Case { +class Case_grille { constructor(x, y) { this.posX = x; this.posy = y; @@ -8,8 +8,52 @@ class Case { } } -<<<<<<< HEAD -======= + + + +let grille = []; +let hauteur = 7; +let largeur = 7; +let number_mines = 10 ; + + + + + +function creerGrille(haut, larg,mine_nb) { + + grille.length = haut; + for (var i=0;i row.startsWith(name + '='))?.split('=')[1]; } ->>>>>>> d322df708ea3bd0301a054980adc49db1c96d181 + function sleep(ms){ return new Promise(resolve => setTimeout(resolve, ms)); @@ -55,20 +99,6 @@ function Cookies() { //Cookies(); -let grille = []; -let hauteur = 7; -let largeur = 7; - -function creerGrille(haut, larg) { - grille.length = haut; - for (var i=0;i>>>>>> 2a2cf84cf311b49f5c290c8502b43f35efa7ec30 } From 49ee2078cf54420e98a359936b0812ac27b548a5 Mon Sep 17 00:00:00 2001 From: "bezza@insa-toulouse.fr" Date: Tue, 31 Dec 2024 20:17:27 +0100 Subject: [PATCH 05/15] correction du jeu --- demineur.html | 37 +------------------------------ demineur.js | 60 ++++++++++++++++++++++++--------------------------- style.css | 6 +++++- 3 files changed, 34 insertions(+), 69 deletions(-) diff --git a/demineur.html b/demineur.html index 2852064..46ff50d 100644 --- a/demineur.html +++ b/demineur.html @@ -49,41 +49,6 @@
- - - - - - - - - - - - +

© 2024 - Tous droits réservés - Le Démineur

diff --git a/demineur.js b/demineur.js index be2ae28..0f6c7a0 100644 --- a/demineur.js +++ b/demineur.js @@ -1,7 +1,7 @@ class Case_grille { constructor(x, y) { this.posX = x; - this.posy = y; + this.posY = y; this.isMine = false; this.number = 0; this.hidden = true; @@ -20,36 +20,32 @@ let number_mines = 10 ; -function creerGrille(haut, larg,mine_nb) { - +function creerGrille(haut, larg, mine_nb) { grille.length = haut; - for (var i=0;i Date: Wed, 1 Jan 2025 14:28:36 +0100 Subject: [PATCH 06/15] ajout debut safe et revelation auto --- demineur.js | 48 +++++++++++++++++++++++++++++++++++------------- 1 file changed, 35 insertions(+), 13 deletions(-) diff --git a/demineur.js b/demineur.js index 0f6c7a0..4f8b63a 100644 --- a/demineur.js +++ b/demineur.js @@ -13,14 +13,14 @@ class Case_grille { let grille = []; let hauteur = 7; -let largeur = 7; +let largeur = 14; let number_mines = 10 ; +let first_click = true ; - -function creerGrille(haut, larg, mine_nb) { +function creerGrille(haut, larg, mine_nb, x_first, y_first) { grille.length = haut; for (var i = 0; i < haut; i++) { grille[i] = Array(larg); @@ -33,7 +33,7 @@ function creerGrille(haut, larg, mine_nb) { let new_x = Math.floor(Math.random() * larg); let new_y = Math.floor(Math.random() * haut); - while (grille[new_y][new_x] == 9) { + 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); } @@ -128,19 +128,42 @@ if (!cookieAccepted){ function selectImage(idCase) { const coords = idCase.split("_") ; - const x = parseInt(coords[0]) ; - const y = parseInt(coords[1]) ; - return("url('case_" + grille[x][y].toString() + ".png')"); + const y = parseInt(coords[0]) ; + const x = parseInt(coords[1]) ; + + if (first_click) { + creerGrille(hauteur,largeur,number_mines,x,y) ; + first_click = false ; + } + + if (grille[y][x] == 0) { + for (var m = Math.max(0, y - 1); m < Math.min(hauteur, y + 2); m++) { + for (var n = Math.max(0, x - 1); n < Math.min(largeur, x + 2); n++) { + const currentCase = document.getElementById(m.toString() + "_" + n.toString()) ; + if (!(currentCase.classList.contains("buttonRevealed"))) { + changeImage(currentCase) ; + } + } + } + } + + return("url('case_" + grille[y][x].toString() + ".png')"); } -function changeImage(mouseEvent) { - if (!(mouseEvent.target.classList.contains("buttonFlagged"))) { - mouseEvent.target.style.background= selectImage(mouseEvent.target.id) ; - mouseEvent.target.classList.add("buttonRevealed") ; + +function changeImage(targetCase) { + if (!(targetCase.classList.contains("buttonFlagged"))) { + targetCase.classList.add("buttonRevealed") ; + targetCase.style.background= selectImage(targetCase.id) ; } } +function changeImageClick(mouseEvent) { + changeImage(mouseEvent.target) ; +} + + function changeImageFlag(rightClick) { rightClick.preventDefault() ; @@ -176,7 +199,7 @@ function grilleButtons(haut, larg) { newCase.classList.add("button_case") ; newCase.id = i.toString() + "_" + j.toString() ; newCase.style.background="url('case_vide.png')" ; - newCase.addEventListener("click", changeImage); + newCase.addEventListener("click", changeImageClick); newCase.addEventListener("contextmenu", changeImageFlag); divGrille.appendChild(newCase) ; @@ -185,5 +208,4 @@ function grilleButtons(haut, larg) { } -creerGrille(hauteur,largeur,number_mines) ; grilleButtons(hauteur,largeur) ; From bf51bb0f0b43da1d9112c24132391b80b5191d80 Mon Sep 17 00:00:00 2001 From: Bocquel Raphael Date: Wed, 1 Jan 2025 14:54:26 +0100 Subject: [PATCH 07/15] =?UTF-8?q?chrono=20li=C3=A9=20aux=20cases?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- demineur.html | 2 +- demineur.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/demineur.html b/demineur.html index 46ff50d..35619cf 100644 --- a/demineur.html +++ b/demineur.html @@ -35,7 +35,7 @@ - + - + - +