function startGame() {
  // Choose the goal coordinates.
  goal = findEnd(originX, originY);
  // Draw the goal.
  var g = document.getElementById('goalLayer');
  var element = document.createElementNS(SVG_NS, 'circle');
  element.setAttribute('r', SQUARE_SIZE / 4);
  element.setAttribute('cx', goal.x * SQUARE_SIZE + SQUARE_SIZE / 2 + 0.5);
  element.setAttribute('cy', goal.y * SQUARE_SIZE + SQUARE_SIZE / 2 + 0.5);
  element.id = 'goal';
  g.appendChild(element);

  // Choose the avatar coordinates.
  avatar = findEnd(goal.x, goal.y);
  avatarPath = [{x: avatar.x, y: avatar.y}];
  // Draw the avatar.
  var g = document.getElementById('avatarLayer');
  var element = document.createElementNS(SVG_NS, 'path');
  element.style.strokeWidth = (SQUARE_SIZE / 6) + 'px';
  element.id = 'avatarPath';
  g.appendChild(element);
  var element = document.createElementNS(SVG_NS, 'circle');
  element.setAttribute('r', SQUARE_SIZE / 4);
  element.setAttribute('cx', avatar.x * SQUARE_SIZE + SQUARE_SIZE / 2 + 0.5);
  element.setAttribute('cy', avatar.y * SQUARE_SIZE + SQUARE_SIZE / 2 + 0.5);
  element.id = 'avatar';
  g.appendChild(element);

  // Allow user input.
  isRunning = true;
}
// Set the goal and allow user interaction.
Set the goal and allow user interaction.
Set the goal and allow user interaction .
function startGame() {
  goal = findEnd(originX, originY);
  var g = document.getElementById('goalLayer');
  var element = document.createElementNS(SVG_NS, 'circle');
  element.setAttribute('r', SQUARE_SIZE / 4);
  element.setAttribute('cx', goal.x * SQUARE_SIZE + SQUARE_SIZE / 2 + 0.5);
  element.setAttribute('cy', goal.y * SQUARE_SIZE + SQUARE_SIZE / 2 + 0.5);
  element.id = 'goal';
  g.appendChild(element);
  avatar = findEnd(goal.x, goal.y);
  avatarPath = [{x: avatar.x, y: avatar.y}];
  var g = document.getElementById('avatarLayer');
  var element = document.createElementNS(SVG_NS, 'path');
  element.style.strokeWidth = (SQUARE_SIZE / 6) + 'px';
  element.id = 'avatarPath';
  g.appendChild(element);
  var element = document.createElementNS(SVG_NS, 'circle');
  element.setAttribute('r', SQUARE_SIZE / 4);
  element.setAttribute('cx', avatar.x * SQUARE_SIZE + SQUARE_SIZE / 2 + 0.5);
  element.setAttribute('cy', avatar.y * SQUARE_SIZE + SQUARE_SIZE / 2 + 0.5);
  element.id = 'avatar';
  g.appendChild(element);
  isRunning = true;
}
function startGame ( ) { goal = findEnd ( originX , originY ) ; var g = document . getElementById ( 'goalLayer' ) ; var element = document . createElementNS ( SVG_NS , 'circle' ) ; element . setAttribute ( 'r' , SQUARE_SIZE / 4 ) ; element . setAttribute ( 'cx' , goal . x * SQUARE_SIZE + SQUARE_SIZE / 2 + 0.5 ) ; element . setAttribute ( 'cy' , goal . y * SQUARE_SIZE + SQUARE_SIZE / 2 + 0.5 ) ; element . id = 'goal' ; g . appendChild ( element ) ; avatar = findEnd ( goal . x , goal . y ) ; avatarPath = [ { x : avatar . x , y : avatar . y } ] ; var g = document . getElementById ( 'avatarLayer' ) ; var element = document . createElementNS ( SVG_NS , 'path' ) ; element . style . strokeWidth = ( SQUARE_SIZE / 6 ) + 'px' ; element . id = 'avatarPath' ; g . appendChild ( element ) ; var element = document . createElementNS ( SVG_NS , 'circle' ) ; element . setAttribute ( 'r' , SQUARE_SIZE / 4 ) ; element . setAttribute ( 'cx' , avatar . x * SQUARE_SIZE + SQUARE_SIZE / 2 + 0.5 ) ; element . setAttribute ( 'cy' , avatar . y * SQUARE_SIZE + SQUARE_SIZE / 2 + 0.5 ) ; element . id = 'avatar' ; g . appendChild ( element ) ; isRunning = true ; }
Set the goal and allow user interaction.
Set the goal and allow user interaction .
// Choose the goal coordinates. // Draw the goal. // Choose the avatar coordinates. // Draw the avatar. // Allow user input.