You could apply the equations of motion assuming negligible air resistance to get the optimal launch angle. Gravity and starting velocity influence the horizontal distance of the object. It also takes into account the parabolic effect while estimating the angle. You may use our projectile motion calculator to make things easier for yourself.