0

通过单击空格,您将获得暂停屏幕。我正在尝试更新分数,但我认为我的 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;

}
}
4

1 回答 1

0

我猜这里

scoreHard = hardScore;
if(score > scoreHard) {

那应该是:

scoreHard = Math.max(score,hardScore);

还有一部分,不应该是这样highScore = score;吗?hardScorehardScore = score;

于 2013-05-30T22:11:55.490 回答