modify ball moving function