snake.js
// Places a new piece of food in a random empty cell.
Places a new piece of food in a random empty cell.
Places a new piece of food in a random empty cell .
function placeFood() {
    if (!isThereEmptyCell()) return;
    var cell = getCell([~~(Math.random() * settings.size[0]), ~~(Math.random() * settings.size[1])]);
    if (cell.className) placeFood();
    else cell.className = 'food';
  }
function placeFood ( ) { if ( ! isThereEmptyCell ( ) ) return ; var cell = getCell ( [ ~ ~ ( Math . random ( ) * settings . size [ 0 ] ) , ~ ~ ( Math . random ( ) * settings . size [ 1 ] ) ] ) ; if ( cell . className ) placeFood ( ) ; else cell . className = 'food' ; }
Places a new piece of food in a random empty cell.
Places a new piece of food in a random empty cell .