Compare commits
2 commits
d322df708e
...
091919c612
Author | SHA1 | Date | |
---|---|---|---|
|
091919c612 | ||
|
d06610ca58 |
5 changed files with 37 additions and 9 deletions
BIN
case_flag.png
Normal file
BIN
case_flag.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 308 B |
BIN
case_zero.png
Normal file
BIN
case_zero.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 263 B |
|
@ -33,8 +33,10 @@
|
||||||
<div id="jeu">
|
<div id="jeu">
|
||||||
<button id="debut_game" onclick="chrono()">GO!</button>
|
<button id="debut_game" onclick="chrono()">GO!</button>
|
||||||
<button id="fin_game" onclick="reset()">CIAO</button>
|
<button id="fin_game" onclick="reset()">CIAO</button>
|
||||||
|
|
||||||
<div id="grille">
|
<div id="grille">
|
||||||
<script type="text/javascript">grilleButtons(7,7);</script>
|
<script type="text/javascript">grilleButtons(7,7);</script>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
40
demineur.js
40
demineur.js
|
@ -7,8 +7,9 @@ class Case {
|
||||||
this.hidden = true;
|
this.hidden = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
<<<<<<< HEAD
|
||||||
|
=======
|
||||||
//Fonction pour créer un cookie.
|
//Fonction pour créer un cookie.
|
||||||
function setCookie(name, value, days) {
|
function setCookie(name, value, days) {
|
||||||
const expires = new Date(Date.now() + days * 864e5).toUTCString();
|
const expires = new Date(Date.now() + days * 864e5).toUTCString();
|
||||||
|
@ -18,6 +19,7 @@ function setCookie(name, value, days) {
|
||||||
function getCookie(name) {
|
function getCookie(name) {
|
||||||
return document.cookie.split('; ').find(row => row.startsWith(name + '='))?.split('=')[1];
|
return document.cookie.split('; ').find(row => row.startsWith(name + '='))?.split('=')[1];
|
||||||
}
|
}
|
||||||
|
>>>>>>> d322df708ea3bd0301a054980adc49db1c96d181
|
||||||
|
|
||||||
function sleep(ms){
|
function sleep(ms){
|
||||||
return new Promise(resolve => setTimeout(resolve, ms));
|
return new Promise(resolve => setTimeout(resolve, ms));
|
||||||
|
@ -69,6 +71,8 @@ function creerGrille(haut, larg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function cookie(){
|
function cookie(){
|
||||||
const popup = document.getElementById('popup');
|
const popup = document.getElementById('popup');
|
||||||
const closePopupButton = document.getElementById('accept-button');
|
const closePopupButton = document.getElementById('accept-button');
|
||||||
|
@ -91,28 +95,50 @@ const cookieAccepted = getCookie('cookiesAccepted');
|
||||||
if (!cookieAccepted){
|
if (!cookieAccepted){
|
||||||
cookie();
|
cookie();
|
||||||
}
|
}
|
||||||
function changeImage(mouseEvent) {
|
|
||||||
mouseEvent.target.style.background="url('case_mine.png')" ;
|
|
||||||
|
function selectImage(idCase) {
|
||||||
|
const coords = idCase.split("_") ;
|
||||||
|
const x = parseInt(coords[0]) ;
|
||||||
|
const y = parseInt(coords[0]) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function changeImage(mouseEvent) {
|
||||||
|
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) {
|
function grilleButtons(haut, larg) {
|
||||||
const divGrille = document.getElementById("grille") ;
|
const divGrille = document.getElementById("grille") ;
|
||||||
for (var i=0;i<haut;i++) {
|
for (var i=0;i<haut;i++) {
|
||||||
for (var j=0;j<larg;j++){
|
for (var j=0;j<larg;j++){
|
||||||
|
|
||||||
var newCase = document.createElement("BUTTON") ;
|
var newCase = document.createElement("BUTTON") ;
|
||||||
newCase.style.gridrow=i.toString() ;
|
newCase.style.gridrow=i.toString() ;
|
||||||
newCase.classList.add("button_case") ;
|
newCase.classList.add("button_case") ;
|
||||||
newCase.id = i.toString() + "_" + j.toString() ;
|
newCase.id = i.toString() + "_" + j.toString() ;
|
||||||
newCase.style.background="url('case_vide.png')" ;
|
newCase.style.background="url('case_vide.png')" ;
|
||||||
newCase.addEventListener("click", changeImage);
|
newCase.addEventListener("click", changeImage);
|
||||||
|
newCase.addEventListener("contextmenu", changeImageFlag);
|
||||||
divGrille.appendChild(newCase) ;
|
divGrille.appendChild(newCase) ;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue