//function to remove cannon balls if they are out of screen or remain stationary for a long time
 void removeUselessBall(CannonBall ball, ArrayList ballList)
 {
     if (ball.getPosition().x < leftBoundary || ball.getPosition().x > rightBoundary || ball.getPosition().y < bottonBoundary)
     {
         //when out of scree, remove the ball from the ball list and destroy it
         ballList.Remove(ball);
         Destroy(ball.GetGameObject());
     }
     else if (Mathf.Abs(ball.getVelocity().x) < 0.0001f)
     {
         //the ball's x-velocity is really small (caused by friction), remove the ball from the ball list and destroy it
         //note that it must been a long time for the ball staying on the ground to have such a small x-velocty
         ballList.Remove(ball);
         Destroy(ball.GetGameObject());
     }
 }