collision(s)


    
    function detectCollisions(){
      //just reflect the ball on a collision
      //a more robust engine could change trajectory of ball based
      //on where the ball hits the paddle
      if(collisionX())
        dx = dx * -1;
      if(collisionY())
        dy = dy * -1;
    }
    
    function collisionX(){
      //check left and right boundaries
      if(ballLeft < 4 || ballLeft > 480)
        return true;
      return false;
    }
    
    function collisionY(){
      //check if at top of playing area
      if(ballTop < 4)
        return true;
      //check to see if ball collided with paddle
      if(ballTop > 450){
        if(ballLeft > paddleLeft && ballLeft < paddleLeft + 64)
          return true;
      }
      return false;
    }