function move(dx, dy) {
  var newX = avatar.x + dx;
  var newY = avatar.y + dy;
  if (isWall(newX, newY, true)) {
    return;
  }
  avatar.x = newX;
  avatar.y = newY;
  var element = document.getElementById('avatar');
  element.setAttribute('cx', avatar.x * SQUARE_SIZE + SQUARE_SIZE / 2 + 0.5);
  element.setAttribute('cy', avatar.y * SQUARE_SIZE + SQUARE_SIZE / 2 + 0.5);

  var lastSpot = avatarPath[avatarPath.length - 2];
  if (lastSpot && lastSpot.x === newX && lastSpot.y === newY) {
    avatarPath.pop();
  } else {
    avatarPath.push({x: newX, y: newY});
  }
  drawPath();

  if (newX === goal.x && newY === goal.y) {
    // Avatar has arrived at the goal.
    isRunning = false;
    document.getElementById('ding').play();
    setTimeout(initMaze, 500);
  }
}
// Move the avatar one step.
Move the avatar one step.
Move the avatar one step .
function move(dx, dy) {
  var newX = avatar.x + dx;
  var newY = avatar.y + dy;
  if (isWall(newX, newY, true)) {
    return;
  }
  avatar.x = newX;
  avatar.y = newY;
  var element = document.getElementById('avatar');
  element.setAttribute('cx', avatar.x * SQUARE_SIZE + SQUARE_SIZE / 2 + 0.5);
  element.setAttribute('cy', avatar.y * SQUARE_SIZE + SQUARE_SIZE / 2 + 0.5);
  var lastSpot = avatarPath[avatarPath.length - 2];
  if (lastSpot && lastSpot.x === newX && lastSpot.y === newY) {
    avatarPath.pop();
  } else {
    avatarPath.push({x: newX, y: newY});
  }
  drawPath();
  if (newX === goal.x && newY === goal.y) {
    isRunning = false;
    document.getElementById('ding').play();
    setTimeout(initMaze, 500);
  }
}
function move ( dx , dy ) { var newX = avatar . x + dx ; var newY = avatar . y + dy ; if ( isWall ( newX , newY , true ) ) { return ; } avatar . x = newX ; avatar . y = newY ; var element = document . getElementById ( 'avatar' ) ; element . setAttribute ( 'cx' , avatar . x * SQUARE_SIZE + SQUARE_SIZE / 2 + 0.5 ) ; element . setAttribute ( 'cy' , avatar . y * SQUARE_SIZE + SQUARE_SIZE / 2 + 0.5 ) ; var lastSpot = avatarPath [ avatarPath . length - 2 ] ; if ( lastSpot && lastSpot . x === newX && lastSpot . y === newY ) { avatarPath . pop ( ) ; } else { avatarPath . push ( { x : newX , y : newY } ) ; } drawPath ( ) ; if ( newX === goal . x && newY === goal . y ) { isRunning = false ; document . getElementById ( 'ding' ) . play ( ) ; setTimeout ( initMaze , 500 ) ; } }
Move the avatar one step.
Move the avatar one step .
// Avatar has arrived at the goal.