parcour pour changer les fils de couleurs

master
pisouvigne 5 years ago
parent 02914539ed
commit 6b61d8ef1b

Binary file not shown.

@ -67,6 +67,11 @@ function createLine(points, id) {
id: id,
tension: tension,
});
var lineObj = {
id: id,
state: false,
};
lines.push(lineObj);
layer.add(line);
}

@ -190,17 +190,48 @@ function changeLineColor(idLine) {
line.stroke(colorline);
}
function changeLineState(idLine) {
let line = null;
lines.forEach(function (element) {
if (element.id === idLine) line = element;
});
var stateLine = line.state == true ? false : true;
line.state = stateLine;
}
function setLineStateTrue(lineId) {
lines.forEach(function (line) {
if (line.id == lineId) line.state = true;
});
}
function setLineStateFalse(lineId) {
lines.forEach(function (line) {
if (line.id == lineId) line.state = false;
});
}
function getLineState(lineId) {
var state = null;
lines.forEach(function (line) {
if (line.id == lineId) state = line.state;
});
return state;
}
function changeLineColorInput(idLine, color) {
let line = stage.findOne("#" + idLine);
line.stroke(color);
}
function changeLineColorBlack(idLine) {
setLineStateFalse(idLine);
let line = stage.findOne("#" + idLine);
line.stroke(colorLineInnactive);
}
function changeLineColorYellow(idLine) {
setLineStateTrue(idLine);
let line = stage.findOne("#" + idLine);
line.stroke(colorLineActive);
}
@ -314,24 +345,26 @@ function checkSortieLogique(logiqueId) {
let line1State, line2State;
let id1Color = stage.findOne("#" + element.id1).stroke();
if (element.type !== "inv") {
let id2Color = stage.findOne("#" + element.id2).stroke();
line2State = getLineState(element.id2);
/*let id2Color = stage.findOne("#" + element.id2).stroke();
if (id2Color == colorLineInnactive) {
line2State = false;
} else {
line2State = true;
}
}*/
}
if (id1Color == colorLineInnactive) {
line1State = getLineState(element.id1);
/*if (id1Color == colorLineInnactive) {
line1State = false;
} else {
line1State = true;
}
}*/
switch (logique.type) {
case "et":
if (line1State == true && line2State == true) {
element.id3.forEach(function (line) {
console.log("oui");
changeLineColorYellow(line);
});
} else {
@ -412,6 +445,29 @@ function isLineCollapsing() {
return isCollapsing;
}
function getLogiqueByLine(idLine) {
var logique = null;
logiques.forEach(function (element) {
if (element.id1 === idLine || element.id2 === idLine) logique = element;
});
return logique;
}
function updateLines(logique) {
if (logique !== null) {
checkSortieLogique(logique.name);
logique.id3.forEach(function (line) {
updateLines(getLogiqueByLine(line));
});
}
}
function lineUpdate(swithId) {
var lineId = getSwitchById(swithId).id3;
var currLogique = getLogiqueByLine(lineId[0]);
updateLines(currLogique);
}
function getRandomArbitrary(min, max) {
return Math.floor(Math.random() * (max - min) + min);
}
@ -431,11 +487,11 @@ function checkLineSwitch(switchId) {
}
function activeSwitch(idSwitch) {
getSwitchById(idSwitch);
var switche = getSwitchById(idSwitch);
changeSwitchColor(switche.id);
switche.id3.forEach(function (element) {
changeLineColor(element);
changeLineState(element);
});
}

@ -5,8 +5,8 @@ function initAllSwitch(mode) {
switche.on('click touchstart', function () {
click++;
activeSwitch(switche.id());
checkAllSortieLogique();
layer.draw();
lineUpdate(element);
checkEnd(mode);
});
switche.on('mouseover', function () {

@ -31,6 +31,9 @@ var timer = new easytimer.Timer();
timer.start();
timer.addEventListener('secondsUpdated', function (e) {
if (timer.getTimeValues().seconds <= timeEnd) {
switchs.forEach(function (element) {
lineUpdate(element);
});
move();
} else {
@ -39,6 +42,7 @@ timer.addEventListener('secondsUpdated', function (e) {
timer.stop();
}
});
function endTime() {
if (!isTuto) {
closeGame();
@ -57,8 +61,7 @@ function endTime() {
document.querySelector("#star1").style.color = "#fe8a71";
document.querySelector("#star2").style.color = "#fe8a71";
document.querySelector("#star3").style.color = "#fe8a71";
}
else if (score > 200 || score < 400) {
} else if (score > 200 || score < 400) {
document.querySelector("#star1").style.color = "#fe8a71";
document.querySelector("#star2").style.color = "#fe8a71";
document.querySelector("#star3").style.color = "#fe8a71";

Loading…
Cancel
Save