暂停屏幕画布不更新

时间:2013-05-30 21:55:56

标签: javascript jquery canvas

点击空格即可获得暂停画面。我正在尝试更新分数,但我认为我的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;

}
}

1 个答案:

答案 0 :(得分:0)

我猜这里

scoreHard = hardScore;
if(score > scoreHard) {

应该是:

scoreHard = Math.max(score,hardScore);

highScore = score;部分hardScore也不应该是hardScore = score;吗?