通过单击空格,您将获得暂停屏幕。我正在尝试更新分数,但我认为我的 if,if else 循环是错误的,但是我没有收到错误。只需单击此处并在播放命中空间时: http ://www.taffatech.com/Snake.html 我认为麻烦的代码是:
function SetSize()
{
if (document.getElementById('Easy').checked)
{
cellSize = 10;
Mode = 1;
}
else if (document.getElementById('Medium').checked)
{
cellSize = 20;
Mode = 2;
}
else if (document.getElementById('Hard').checked)
{
cellSize = 30;
Mode = 3;
}
}
function init()
{
if (Mode == 1)
{
scoreEasy = easyScore;
if(score > scoreEasy) {
easyScore = scoreEasy;
}
}
else if (Mode == 2)
{
scoreMedium = mediumScore;
if(score > scoreMedium) {
mediumScore = score;
}
}
else if (Mode == 3)
{
scoreHard = hardScore;
if(score > scoreHard) {
highScore = score;
}
}