function init() {
  fixLinks();

  // Configure difficulty mode.
  var m = document.cookie.match(/difficulty=([012])/);
  var difficulty = Number(m ? m[1] : 0);
  document.getElementById('difficulty').selectedIndex = difficulty;
  registerOptions('difficulty');

  // Set size based on difficulty.
  HEIGHT = HEIGHTS[difficulty];
  WIDTH = WIDTHS[difficulty];
  SQUARE_SIZE = SQUARE_SIZES[difficulty];
  var svg = document.getElementById('landscape');
  svg.setAttribute('height', SQUARE_SIZE * HEIGHT + 1);
  svg.setAttribute('width', SQUARE_SIZE * WIDTH + 1);

  // Start button is only for restart in this game, but add event handler now.
  document.getElementById('start').addEventListener('click', startButton);
  document.addEventListener('keypress', keyPress);
  document.addEventListener('keydown', keyDown);

  // Start the first maze from a random place.
  avatar.x = Math.floor(Math.random() * WIDTH);
  avatar.y = Math.floor(Math.random() * HEIGHT);

  // Draw the maze and goal.
  initMaze();
}
// Start-up initialization code.  Run once.
Start-up initialization code.  Run once.
Start - up initialization code . Run once .
function init() {
  fixLinks();
  var m = document.cookie.match(/difficulty=([012])/);
  var difficulty = Number(m ? m[1] : 0);
  document.getElementById('difficulty').selectedIndex = difficulty;
  registerOptions('difficulty');
  HEIGHT = HEIGHTS[difficulty];
  WIDTH = WIDTHS[difficulty];
  SQUARE_SIZE = SQUARE_SIZES[difficulty];
  var svg = document.getElementById('landscape');
  svg.setAttribute('height', SQUARE_SIZE * HEIGHT + 1);
  svg.setAttribute('width', SQUARE_SIZE * WIDTH + 1);
  document.getElementById('start').addEventListener('click', startButton);
  document.addEventListener('keypress', keyPress);
  document.addEventListener('keydown', keyDown);
  avatar.x = Math.floor(Math.random() * WIDTH);
  avatar.y = Math.floor(Math.random() * HEIGHT);
  initMaze();
}
function init ( ) { fixLinks ( ) ; var m = document . cookie . match ( / difficulty=([012]) / ) ; var difficulty = Number ( m ? m [ 1 ] : 0 ) ; document . getElementById ( 'difficulty' ) . selectedIndex = difficulty ; registerOptions ( 'difficulty' ) ; HEIGHT = HEIGHTS [ difficulty ] ; WIDTH = WIDTHS [ difficulty ] ; SQUARE_SIZE = SQUARE_SIZES [ difficulty ] ; var svg = document . getElementById ( 'landscape' ) ; svg . setAttribute ( 'height' , SQUARE_SIZE * HEIGHT + 1 ) ; svg . setAttribute ( 'width' , SQUARE_SIZE * WIDTH + 1 ) ; document . getElementById ( 'start' ) . addEventListener ( 'click' , startButton ) ; document . addEventListener ( 'keypress' , keyPress ) ; document . addEventListener ( 'keydown' , keyDown ) ; avatar . x = Math . floor ( Math . random ( ) * WIDTH ) ; avatar . y = Math . floor ( Math . random ( ) * HEIGHT ) ; initMaze ( ) ; }
Start-up initialization code.
Start - up initialization code .
// Configure difficulty mode. // Set size based on difficulty. // Start button is only for restart in this game, but add event handler now. // Start the first maze from a random place. // Draw the maze and goal.