所以我有这个游戏,分数一直在增加,但是没有输。当玩家退出游戏时,我要保存并存储游戏高分并在另一页中显示。我该怎么办?
checkColorMatch = function() {
if (curColor == nextMatchColor) {
++streak;
dur -= 10;
if (dur < minDur) {
dur = minDur;
}
streakCounter.innerHTML = streak;
} else {
streak = 0;
dur = 2000;
streakCounter.innerHTML = "";
}
prevMatchColor = nextMatchColor;
nextMatchColor = chooseColor();
boxes[0].className = "box " + colors[prevMatchColor];
boxes[1].className = "box " + colors[nextMatchColor];
rerun();
setTimeout(checkColorMatch,dur);
};
main.classList.add("run");
jello.classList.add(colors[curColor]);
boxes[0].classList.add(colors[prevMatchColor]);
boxes[1].classList.add(colors[nextMatchColor]);
for (b in boxes) {
if (b < boxes.length) {
boxes[b].classList.add(colors[chooseColor()]);
}
}
setTimeout(checkColorMatch,dur);
document.querySelector(".click-area").addEventListener("click",cycleColor);
document.addEventListener("keydown",function(e) {
if (e.keyCode == 32) {
cycleColor();
}
});