New answers tagged

2

DMGregory guided me towards a good solution explained in this article: Use a fixed timestep This solution allows the total decoupling of the simulation and rendering frequency, while allowing for a fixed timestep for the simulation part. Visual smoothness is preserved by interpolating between the previous and current (last) state of simulation with a ...


0

The equation of motion under constant acceleration is: $$\vec p (t) = \vec p_0 + \vec v_0 \cdot t + \frac {\vec a} 2 t^2$$ So if you didn't have your drag, you could modify your code like so... if(button_pressed) vel_x = run_speed; else // TODO // pos_x += vel_x * dt; pos_y += vel_y * dt + 0.5 * gravity * dt * dt; vel_y += gravity * dt; ...


Top 50 recent answers are included