It's a pretty simple undergraduate physics problem. You start with Newton's law for the x- and y-directions:


with initial conditions:




Where Q is the initial speed of the projectile and theta is the angle measured counterclockwise from the horizon if the gun points to the right.
So if you integrate each one once w.r.t. time, you get:


Applying initial conditions:


Integrating a second time gives:


Applying initial conditions again:

Making the substitutions gives the final equations that you want for the (u, v) position of the projectile from the moment the gun goes off:


If you put the origin of the coordinate system at the gun muzzle exit, then the two initial displacements are zero.
Now you have two equations for the (u, v) position of the projectile. You can plug in the initial speed of the projectile and the angle of the gun as measured from the horizon at zero, pointing to the right.
You just start with time at zero, pick an increment in time, and loop for as long a time interval as you like. You plug the current value of time into those equations, evaluate the results, increment the time, and repeat.
Let's imagine that you angle the gun at forty-five degrees counterclockwise from the horizon and fire a projectile at 1000 in/sec. You can step through time and see the projectile move up and to the right in a parabolic path until it reaches its apex and then starts to fall back to the horizon. Eventually your y-displacement will return back to zero and then continue into negative territory, as if you had shot it from the edge of a cliff.
If you want to know how far the projectile goes before it hits the ground, just stop the time loop when the height becomes less than or equal to zero:

Here's a Java implementation for you:
package physics;
/**
* CannonSimulator simulates shooting a projectile. Users are responsible for making
* sure that all constants use consistent units (e.g. meters for length, seconds for
* time, kg for mass, etc.)
* @author Michael
* @since 6/14/12 9:47 PM
* @link http://stackoverflow.com/questions/10935060/2d-projectile-tracing-path-clarification/11043389#11043389
*/
public class CannonSimulator {
private double m;
private double g;
private double q;
private double theta;
public static void main(String[] args) {
double m = ((args.length > 0) ? Double.valueOf(args[0]) : 1.0); // default mass is 1 kg
double g = ((args.length > 1) ? Double.valueOf(args[1]) : 9.8); // default gravity is 9.8 m/sec^2
double q = ((args.length > 2) ? Double.valueOf(args[2]) : 100.0); // default velocity is 100 m/sec
double theta = ((args.length > 3 ? Double.valueOf(args[3]) : Math.PI/4.0)); // default angle is 45 degrees
CannonSimulator simulator = new CannonSimulator(m, g, q, theta);
double t = 0.0;
double dt = 0.001; // time increment of 0.1 seconds
while (simulator.v(t) >= 0.0) {
System.out.println(String.format("time: %10.3f u: %10.3f v: %10.3f", t, simulator.u(t), simulator.v(t)));
t += dt;
}
}
public CannonSimulator(double m, double g, double q, double theta) {
if (m <= 0.0) throw new IllegalArgumentException("mass must be greater than zero");
if (g <= 0.0) throw new IllegalArgumentException("gravity must be greater than zero");
if (q <= 0.0) throw new IllegalArgumentException("velocity must be greater than zero");
this.m = m;
this.g = g;
this.q = q;
this.theta = theta;
}
public double v(double time) {
return time*(q*Math.sin(theta) - g*time/m);
}
public double u(double time) {
return time*q*Math.cos(theta);
}
}
That's how to solve this problem.