Hi,
Following function is working fine when we load page 1st time, but not working when we refresh the page in Firefox (but working fine in Chrome)
Code:
function start() {
getXY();
rndmX = x, rndmY = y;
snake.Body.unshift([rndmX,rndmY]);
resetInterval();
direction = snake.dir[Math.round(Math.random()*3)];
getFood();
enable('#restart');
$('#restart').css({background:'#9B3378'});
enable('#pause');
$('#pause').css({background:'#E09926'});
enable('#stop');
$('#stop').css({background:'#AD4343'});
cnvs.focus();
disable('#start');
$('#score').html(score);
}
Following are the functions being called in above functions:
Code:
function getRN(max) {
var n, mod;
n = Math.round(Math.random()*max);
mod = n%grid;
n = n - mod;
n = n >max?max:n;
return n;
}
function getXY() {
x = getRN(maxX);
y = getRN(maxY);
return x,y;
}
function resetInterval() {
clearInterval(interval);
interval = 0
interval = setInterval(moveSnake, snake.speed);
}
Please help ... Thank you in advance