function initMaze() {
  // Clear old SVG walls and goal.
  var g = document.getElementById('wallLayer');
  while (g.firstChild) {
    g.removeChild(g.firstChild);
  }
  g = document.getElementById('goalLayer');
  while (g.firstChild) {
    g.removeChild(g.firstChild);
  }
  g = document.getElementById('avatarLayer');
  while (g.firstChild) {
    g.removeChild(g.firstChild);
  }
  // Initialize the wall grid to be solid.
  walls.length = 0;
  for (var x = 0; x < WIDTH; x++) {
    walls[x] = [];
    for (var y = 0; y < HEIGHT; y++) {
      walls[x][y] = true;
    }
  }

  // Use the avatar/goal location in the previous maze as the origin for the
  // next maze.
  originX = avatar.x;
  originY = avatar.y;
  initMaze.horizon = [{x: originX, y: originY}];
  initMazeStep();
}
// Clear any existing maze.  Create a new maze.
Clear any existing maze.  Create a new maze.
Clear any existing maze . Create a new maze .
function initMaze() {
  var g = document.getElementById('wallLayer');
  while (g.firstChild) {
    g.removeChild(g.firstChild);
  }
  g = document.getElementById('goalLayer');
  while (g.firstChild) {
    g.removeChild(g.firstChild);
  }
  g = document.getElementById('avatarLayer');
  while (g.firstChild) {
    g.removeChild(g.firstChild);
  }
  walls.length = 0;
  for (var x = 0; x < WIDTH; x++) {
    walls[x] = [];
    for (var y = 0; y < HEIGHT; y++) {
      walls[x][y] = true;
    }
  }
  originX = avatar.x;
  originY = avatar.y;
  initMaze.horizon = [{x: originX, y: originY}];
  initMazeStep();
}
function initMaze ( ) { var g = document . getElementById ( 'wallLayer' ) ; while ( g . firstChild ) { g . removeChild ( g . firstChild ) ; } g = document . getElementById ( 'goalLayer' ) ; while ( g . firstChild ) { g . removeChild ( g . firstChild ) ; } g = document . getElementById ( 'avatarLayer' ) ; while ( g . firstChild ) { g . removeChild ( g . firstChild ) ; } walls . length = 0 ; for ( var x = 0 ; x < WIDTH ; x ++ ) { walls [ x ] = [ ] ; for ( var y = 0 ; y < HEIGHT ; y ++ ) { walls [ x ] [ y ] = true ; } } originX = avatar . x ; originY = avatar . y ; initMaze . horizon = [ { x : originX , y : originY } ] ; initMazeStep ( ) ; }
Clear any existing maze.
Clear any existing maze .
// Clear old SVG walls and goal. // Initialize the wall grid to be solid. // Use the avatar/goal location in the previous maze as the origin for the // next maze.