function init() {
  fixLinks();

  var m = document.cookie.match(/difficulty=([012])/);
  var difficultyIndex = m ? m[1] : 0;
  document.getElementById('difficulty').selectedIndex = difficultyIndex;
  SPEED = [400, 200, 100][difficultyIndex];
  // Easy - Food is never next to a wall.
  // Normal - Food is never in the wrap doors.
  // Hard - Food is anywhere.
  foodMargin = [2, 1, 0][difficultyIndex];
  m = document.cookie.match(/players=([12])/);
  if (m && m[1] === '2') {
    player2 = true;
  }
  document.getElementById('players').selectedIndex = player2 ? 1 : 0;
  registerOptions('players', 'difficulty');
  document.getElementById('player2keys').style.display =
    (player2 ? 'block' : 'none');

  injectTable();
  initBorders();
  document.getElementById('start').addEventListener('click', startGame);

  document.addEventListener('keydown', keydown);
  document.addEventListener('keypress', keyPress);
}
// On page load, initialize the event handlers and show the start button.
On page load, initialize the event handlers and show the start button.
On page load initialize the event handlers and show the start button .
function init() {
  fixLinks();
  var m = document.cookie.match(/difficulty=([012])/);
  var difficultyIndex = m ? m[1] : 0;
  document.getElementById('difficulty').selectedIndex = difficultyIndex;
  SPEED = [400, 200, 100][difficultyIndex];
  foodMargin = [2, 1, 0][difficultyIndex];
  m = document.cookie.match(/players=([12])/);
  if (m && m[1] === '2') {
    player2 = true;
  }
  document.getElementById('players').selectedIndex = player2 ? 1 : 0;
  registerOptions('players', 'difficulty');
  document.getElementById('player2keys').style.display =
    (player2 ? 'block' : 'none');
  injectTable();
  initBorders();
  document.getElementById('start').addEventListener('click', startGame);
  document.addEventListener('keydown', keydown);
  document.addEventListener('keypress', keyPress);
}
function init ( ) { fixLinks ( ) ; var m = document . cookie . match ( / difficulty=([012]) / ) ; var difficultyIndex = m ? m [ 1 ] : 0 ; document . getElementById ( 'difficulty' ) . selectedIndex = difficultyIndex ; SPEED = [ 400 , 200 , 100 ] [ difficultyIndex ] ; foodMargin = [ 2 , 1 , 0 ] [ difficultyIndex ] ; m = document . cookie . match ( / players=([12]) / ) ; if ( m && m [ 1 ] === '2' ) { player2 = true ; } document . getElementById ( 'players' ) . selectedIndex = player2 ? 1 : 0 ; registerOptions ( 'players' , 'difficulty' ) ; document . getElementById ( 'player2keys' ) . style . display = ( player2 ? 'block' : 'none' ) ; injectTable ( ) ; initBorders ( ) ; document . getElementById ( 'start' ) . addEventListener ( 'click' , startGame ) ; document . addEventListener ( 'keydown' , keydown ) ; document . addEventListener ( 'keypress' , keyPress ) ; }
On page load, initialize the event handlers and show the start button.
On page load initialize the event handlers and show the start button .
// Easy - Food is never next to a wall. // Normal - Food is never in the wrap doors. // Hard - Food is anywhere.