var Ghost = function(args) {
  this.x = args.startX;
  this.y = args.startY;
  this.direction = args.direction ? args.direction : "left";
  this.speed = GHOST_MOVE_DELAY;
  this.context = args.context;
  this.name = args.name;
  this.color = nameToColor[args.name];
  this.movementMode = args.mode ? args.mode : "scatter";
  this.targetTile = GHOST_CORNERS[this.name];
}
Ghost.blinkyTarget = function(args) {
  return {
    x: args.coords.x,
    y: args.coords.y
  }
};
Ghost.prototype.isCentered = function() {
  return this.x % 8 == 4 && this.y % 8 == 4;
};
Ghost.prototype.getClearDimensions = function() {
  return {
    x: this.x - 7,
    y: this.y - 7,
    w: 14,
    h: 16
  }
};
Ghost.prototype.move = function() {
  switch(this.direction){
    case "up": this.y--; break;
    case "down": this.y++; break;
    case "left": this.x--; break;
    case "right": this.x++; break;
  }
};
Ghost.prototype.exitHouse = function() {
  this.setMode("exitting");
  if(this.x < BOARD_WIDTH / 2) {
    this.direction = "right";
  }
  else if(this.x > BOARD_WIDTH / 2) {
    this.direction = "left";
  }
  else {
    this.direction = "up";
  }
  if(this.y <= 116) {
    this.setMode("scatter");
  }
};
Ghost.prototype.setMode = function(modeName) {
  if(GHOST_MODES.includes(modeName)) {
    this.movementMode = modeName;
  }
};

var Ghost = function(args) {
  this.x = args.startX;
  this.y = args.startY;
  this.direction = args.direction ? args.direction : "left";
  this.speed = GHOST_MOVE_DELAY;
  this.context = args.context;
  this.name = args.name;
  this.color = nameToColor[args.name];
  this.movementMode = args.mode ? args.mode : "scatter";
  this.targetTile = GHOST_CORNERS[this.name];
}
Ghost.blinkyTarget = function(args) {
  return {
    x: args.coords.x,
    y: args.coords.y
  }
};
Ghost.pinkyTarget = function(args) {
  var xMod = 0;
  var yMod = 0;
  switch(args.direction) {
    case "up": yMod -= 4; break;
    case "down": yMod += 4; break;
    case "left": xMod -= 4; break;
    case "right": xMod += 4; break;
  }
  return {
    x: args.coords.x + xMod,
    y: args.coords.y + yMod
  }
};
Ghost.prototype.isCentered = function() {
  return this.x % 8 == 4 && this.y % 8 == 4;
};
Ghost.prototype.getClearDimensions = function() {
  return {
    x: this.x - 7,
    y: this.y - 7,
    w: 14,
    h: 16
  }
};
Ghost.prototype.move = function() {
  switch(this.direction){
    case "up": this.y--; break;
    case "down": this.y++; break;
    case "left": this.x--; break;
    case "right": this.x++; break;
  }
};
Ghost.prototype.exitHouse = function() {
  this.setMode("exitting");
  if(this.x < BOARD_WIDTH / 2) {
    this.direction = "right";
  }
  else if(this.x > BOARD_WIDTH / 2) {
    this.direction = "left";
  }
  else {
    this.direction = "up";
  }
  if(this.y <= 116) {
    this.setMode("scatter");
  }
};
Ghost.prototype.setMode = function(modeName) {
  if(GHOST_MODES.includes(modeName)) {
    this.movementMode = modeName;
  }
};

Add Ghost class function to calculate Pinky's target