détection réparée + début color picker

le problème venait plus de la fonction de création des vitraux que du reste, copyMDArray ignorait le true au début, il a fallu le rajouter après l'ajout des dots...
master
adplantade 5 years ago
parent aab5edea8f
commit 552903c3da

@ -42,7 +42,6 @@ modes.forEach(element => {
document.getElementById("btn_play").style.display="flex"; document.getElementById("btn_play").style.display="flex";
document.getElementById("btn_play_des").style.display="none"; document.getElementById("btn_play_des").style.display="none";
} }
dispHighscores();
}); });
} }
}); });
@ -65,7 +64,6 @@ diffs.forEach(element => {
document.getElementById("btn_play").style.display="flex"; document.getElementById("btn_play").style.display="flex";
document.getElementById("btn_play_des").style.display="none"; document.getElementById("btn_play_des").style.display="none";
} }
dispHighscores();
}); });
}) })

@ -2,6 +2,8 @@
<head> <head>
<title>On The Dot</title> <title>On The Dot</title>
<link rel="stylesheet" type="text/css" href="index.css"/> <link rel="stylesheet" type="text/css" href="index.css"/>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@simonwep/pickr/dist/themes/monolith.min.css"/> <!-- 'monolith' theme -->
<script src="https://cdn.jsdelivr.net/npm/@simonwep/pickr/dist/pickr.min.js"></script>
</head> </head>
<body> <body>
@ -83,6 +85,9 @@ Jouer la partie en : </br>
<input type="radio" id="no_pause" value="0" name="pause"> <input type="radio" id="no_pause" value="0" name="pause">
<label for="no_pause">Non</label> <label for="no_pause">Non</label>
<div> Choisir les couleurs des points (ne fonctionne pas en mode "gemmes" ou "les deux")
<div class="color-picker"></div>
<p> <p>
<button id="btn_options" onClick="saveOptions()">Valider</button> <button id="btn_options" onClick="saveOptions()">Valider</button>
</p> </p>

@ -49,3 +49,66 @@ document.getElementById((getCookie("displayMode")!="" ? getCookie("displayMode")
document.getElementById("range_dots").value= (getCookie("dotsAmount")!="" ? getCookie("dotsAmount") : 4); document.getElementById("range_dots").value= (getCookie("dotsAmount")!="" ? getCookie("dotsAmount") : 4);
output.innerHTML = (getCookie("dotsAmount")!="" ? getCookie("dotsAmount") : 4); output.innerHTML = (getCookie("dotsAmount")!="" ? getCookie("dotsAmount") : 4);
// Simple example, see optional options for more configuration.
const pickr = Pickr.create({
el: '.color-picker',
theme: 'monolith', // or 'monolith', or 'nano'
swatches: [
'rgba(244, 67, 54, 1)',
'rgba(233, 30, 99, 0.95)',
'rgba(156, 39, 176, 0.9)',
'rgba(103, 58, 183, 0.85)',
'rgba(63, 81, 181, 0.8)',
'rgba(33, 150, 243, 0.75)',
'rgba(3, 169, 244, 0.7)',
'rgba(0, 188, 212, 0.7)',
'rgba(0, 150, 136, 0.75)',
'rgba(76, 175, 80, 0.8)',
'rgba(139, 195, 74, 0.85)',
'rgba(205, 220, 57, 0.9)',
'rgba(255, 235, 59, 0.95)',
'rgba(255, 193, 7, 1)'
],
components: {
// Main components
preview: true,
opacity: true,
hue: true,
// Input / output Options
interaction: {
hex: true,
rgba: true,
hsla: true,
hsva: true,
cmyk: true,
input: true,
clear: true,
save: true
}
}
});
pickr.on('init', instance => {
console.log('init', instance);
}).on('hide', instance => {
console.log('hide', instance);
}).on('show', (color, instance) => {
console.log('show', color, instance);
}).on('save', (color, instance) => {
console.log('save', color, instance);
}).on('clear', instance => {
console.log('clear', instance);
}).on('change', (color, instance) => {
console.log('change', color, instance);
}).on('changestop', instance => {
console.log('changestop', instance);
}).on('cancel', instance => {
console.log('cancel', instance);
}).on('swatchselect', (color, instance) => {
console.log('swatchselect', color, instance);
});

@ -97,7 +97,7 @@ function genVitraux()
var mat = matrix(6,6); var mat = matrix(6,6);
var x; var x;
var y; var y;
var baseVitrail=[true]; var baseVitrail=[];
var tries; var tries;
for(var cpt=0;cpt<dotsAmount;cpt++) for(var cpt=0;cpt<dotsAmount;cpt++)
@ -105,13 +105,10 @@ function genVitraux()
x=getRandomInt(6)-1; x=getRandomInt(6)-1;
y=getRandomInt(6)-1; y=getRandomInt(6)-1;
console.log("mat :"+mat[x][y]);
while(mat[x][y]!=0 && tries!=20) while(mat[x][y]!=0 && tries!=20)
{ {
x=getRandomInt(6)-1; x=getRandomInt(6)-1;
y=getRandomInt(6)-1; y=getRandomInt(6)-1;
console.log("["+x+","+y+"] ->"+cpt);
tries++; tries++;
} }
@ -122,14 +119,13 @@ function genVitraux()
x-=2; x-=2;
y-=2; y-=2;
baseVitrail.push([(x>0 ? x : x-1),(y>0 ? y : y-1),colors[cpt]]); baseVitrail.push([(x>0 ? x : x-1),(y>0 ? y : y-1),colors[cpt]]);
console.log("mat = "+mat);
tries=0; tries=0;
} }
//console.log("final : "+baseVitrail+" et :"+Array.isArray(baseVitrail));
for(var i=1;i<5;i++) for(var i=1;i<5;i++)
{ {
eval("tab"+i+"=copyMDArray(baseVitrail)"); eval("tab"+i+"=copyMDArray(baseVitrail)");
eval("tab"+i+".unshift(true)");
} }
} }
@ -195,20 +191,26 @@ function empiler(obj=false)
if(!obj) if(!obj)
{ {
tabTotal=[]; tabTotal=[];
console.log("tabtotal début "+tabTotal);
console.log("tab1 = "+tab1);
if(tab1[0]) if(tab1[0])
{ {
console.log("tab1 = "+tab1);
tab1.forEach(element => { tab1.forEach(element => {
if(Array.isArray(element)) console.log("element t1="+element);
if(Array.isArray(element) && element.length!=0)
{ {
tabTotal.push(element); tabTotal.push(element);
//console.log("tabtotal tab1 "+tabTotal+"|");
} }
}) })
} }
if(tab2[0]){ if(tab2[0]){
console.log("tab2 = "+tab2);
tab2.forEach(element => { tab2.forEach(element => {
if(Array.isArray(element)) console.log("element t2="+element);
if(Array.isArray(element) && element.length!=0)
{ {
colors.forEach(col => { colors.forEach(col => {
test=[element[0],element[1],col]; test=[element[0],element[1],col];
@ -217,6 +219,7 @@ function empiler(obj=false)
}) })
if(!exists) if(!exists)
tabTotal.push(element); tabTotal.push(element);
//console.log("tabtotal tab2 "+tabTotal+"|");
exists=false; exists=false;
} }
}) })
@ -224,8 +227,10 @@ function empiler(obj=false)
if(tab3[0]) if(tab3[0])
{ {
console.log("tab3 = "+tab3);
tab3.forEach(element => { tab3.forEach(element => {
if(Array.isArray(element)){ console.log("element t3="+element);
if(Array.isArray(element) && element.length!=0){
colors.forEach(col => { colors.forEach(col => {
test=[element[0],element[1],col]; test=[element[0],element[1],col];
if(!exists) if(!exists)
@ -233,14 +238,17 @@ function empiler(obj=false)
}) })
if(!exists) if(!exists)
tabTotal.push(element); tabTotal.push(element);
//console.log("tabtotal tab3 "+tabTotal+"|");
exists=false; exists=false;
} }
}) })
} }
if(tab4[0]){ if(tab4[0]){
console.log("tab4 = "+tab4);
tab4.forEach(element => { tab4.forEach(element => {
if(Array.isArray(element)) console.log("element t4="+element);
if(Array.isArray(element) && element.length!=0)
{ {
colors.forEach(col => { colors.forEach(col => {
test=[element[0],element[1],col]; test=[element[0],element[1],col];
@ -249,6 +257,7 @@ function empiler(obj=false)
}) })
if(!exists) if(!exists)
tabTotal.push(element); tabTotal.push(element);
//console.log("tabtotal tab4 "+tabTotal+"|");
exists=false; exists=false;
} }
}) })
@ -492,6 +501,7 @@ function checkAllOK(){
for(i=0;i<tabTotal.length;i++) for(i=0;i<tabTotal.length;i++)
{ {
const result = verifTab.filter(point => point.toString()==tabObjCmp[i].toString()); const result = verifTab.filter(point => point.toString()==tabObjCmp[i].toString());
console.log(verifTab.filter(point => point.toString()+" et "+tabObjCmp[i].toString()));
exists*=result.length; exists*=result.length;
} }
} }

Loading…
Cancel
Save