Commit 5875851f authored by Timothée Giet's avatar Timothée Giet

clockgame, avoid initialize on the answer

parent 0d45d859
......@@ -37,8 +37,12 @@ function initLevel() {
items.bar.level = currentLevel + 1
items.numberOfTry = items.levels[currentLevel].numberOfSubLevels
items.currentH = Math.floor(Math.random() * 12)
items.targetH = Math.floor(Math.random() * 12)
while(items.currentH === items.targetH) {
items.currentH = Math.floor(Math.random() * 12)
}
items.minutesHandVisible = items.levels[currentLevel].displayMinutesHand
if(!items.minutesHandVisible) {
......@@ -48,10 +52,12 @@ function initLevel() {
else if(items.levels[currentLevel].fixedMinutes !== undefined) {
items.currentM = Math.floor(Math.random() * 60)
items.targetM = items.levels[currentLevel].fixedMinutes
differentCurrentM()
}
else {
items.currentM = Math.floor(Math.random() * 60)
items.targetM = Math.floor(Math.random() * 60)
differentCurrentM()
}
items.secondsHandVisible = items.levels[currentLevel].displaySecondsHand
......@@ -62,10 +68,12 @@ function initLevel() {
else if(items.levels[currentLevel].fixedSeconds !== undefined) {
items.currentS = Math.floor(Math.random() * 60)
items.targetS = items.levels[currentLevel].fixedSeconds
differentCurrentS()
}
else {
items.currentS = Math.floor(Math.random() * 60)
items.targetS = Math.floor(Math.random() * 60)
differentCurrentS()
}
if(items.levels[currentLevel].zonesVisible !== undefined) {
......@@ -97,6 +105,18 @@ function initLevel() {
}
}
function differentCurrentM() {
while(items.currentM === items.targetM) {
items.currentM = Math.floor(Math.random() * 60)
}
}
function differentCurrentS() {
while(items.currentS === items.targetS) {
items.currentS = Math.floor(Math.random() * 60)
}
}
function nextTry() {
if (items.numberOfTry <= ++items.currentTry) {
items.currentTry = 0
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment