So xSpeed and xPos are easy to deal with since xSpeed is a constant and doesn't change with time.
ySpeed however changes continuously with time under the influence of gravity, and this will have to be dealt with. First your equation:
ySpeed = V * sin(A)
This only defines y's starting speed, that's it, and so you can only use this equation at the beginning of your calculations. Perhaps you should think of V * sin(A) as ySpeed0. So to do this correctly, you'd have this equation
before the loop. something like so:
|
Code:
|
// pseudocode
double xSpeed = v * cos(angle)
double ySpeed = v * sin(angle)
loop incrementing time {
xPos = xPos + xSpeed * time;
yPos = yPos + ySpeed * time;
ySpeed = ySpeed - gravity * time;
} |