function checkCollisions(item) {
  if (
    item.position.x + item.velocity.x + item.newimg.width > gameBoardWidth ||
    item.position.x + item.velocity.x < 0
  ) {
    item.velocity.x = -item.velocity.x;
    item.direction = (item.direction + 1) % 2;
  }
  if (
    item.position.y + item.velocity.y + item.newimg.height > gameBoardHeight ||
    item.position.y + item.velocity.y < 0
  ) {
    item.velocity.y = -item.velocity.y;
  }
}
//  checks to see if the pacmen has collided with one of the four sides.
checks to see if the pacmen has collided with one of the four sides.
checks to see if the pacmen has collided with one of the four sides .
function checkCollisions(item) {
  if (
    item.position.x + item.velocity.x + item.newimg.width > gameBoardWidth ||
    item.position.x + item.velocity.x < 0
  ) {
    item.velocity.x = -item.velocity.x;
    item.direction = (item.direction + 1) % 2;
  }
  if (
    item.position.y + item.velocity.y + item.newimg.height > gameBoardHeight ||
    item.position.y + item.velocity.y < 0
  ) {
    item.velocity.y = -item.velocity.y;
  }
}
function checkCollisions ( item ) { if ( item . position . x + item . velocity . x + item . newimg . width > gameBoardWidth || item . position . x + item . velocity . x < 0 ) { item . velocity . x = - item . velocity . x ; item . direction = ( item . direction + 1 ) % 2 ; } if ( item . position . y + item . velocity . y + item . newimg . height > gameBoardHeight || item . position . y + item . velocity . y < 0 ) { item . velocity . y = - item . velocity . y ; } }
checks to see if the pacmen has collided with one of the four sides.
checks to see if the pacmen has collided with one of the four sides .