void update(double time)
velocity.x = acceleration.x * time;
velocity.y = acceleration.y * time;
position.x = velocity.x * time;
position.y = velocity.y * time;
I'm don't think the above will work.
It is true that
position.y = velocity.y * time
, if velocity is constant (no acceleration)
And this is true,
velocity.x = acceleration.x * time
, if acceleration is const.
What I would use is:
y = y_intial + velocity_y_inital * delta_t + .5 * acceleration_y * delta_t^2
But this is only valid for const acceleration as well. So you need to restart the clock every time acceleration changes, keep track of your velocity and position, and use them as initial conditions in the subsequent chunk of time.
delta_t = 0
y_initial = y
velocity_y_initial = veloctity_y_initial + delta_t * acceleration_y
now update acceleration
thrust is force. force = mass * acceleration, acceleration = force / mass
Fnet = Fgrav + Fthrust = mass*acceleration_net
Force of gravity = -9.8 * mass
Force of thrust = accleration_thrust * mass
-9.8 + acceleration_thrust = acceleration
So you can just add the accelerations due to gravity and thrust.
Now also consider the way in which thrust is controlled by the user. You might want an upper limit for the throttle value. You might want a non-linear relationship between throttle value and thrust. I would find a function which models the relationship I'm looking for. Probably something logarithmic.
You don't need momentum unless your dealing with collisions where you can use conservation of momentum to determine the results of the collisions.
There might be a better way to do it, I don't know, this is how I have gone about it in the past.