Write code to simulate a ballistic projectile in non-uniform gravity.