//check if balls collide public bool checkBallCollision(Ball otherBall) { xDist = otherBall.getX()-xPos;//dx yDist = otherBall.getY()-yPos;//dy float radDist = radius + otherBall.getRadius(); if (radDist * radDist >= (xDist * xDist + yDist * yDist) && inPlay == true && otherBall.inPlay == true) //check if distance is bigger than the balls touching range { return true; } else { return false; } }