I am having a little trouble getting the jumping physics right in a 2D platformer I'm working on. What I'm trying to do is set an impulse value, and then let the gravity force slow it down, and eventually reverse it, but it isn't quite working. The result I'm seeing is the player instantly appears at the peak of the jump, and then begins to fall. I'm sure I'm doing something wrong but I'm not seeing it. My update step looks like this:
update(double time)
{
ddx_ = (forceX_ / mass_) * time;
ddy_ = (forceY_ / mass_) * time;
impulseX_ *= time;
impulseY_ *= time;
dx_ += (ddx_ + impulseX_);
dy_ += (ddy_ + impulseY_);
dx_ += (dx_ * linearDampX_);
dy_ += (dy_ * linearDampY_);
dx_ *= time;
dy_ *= time;
x_ += dx_;
y_ += dy_;
// Impulse should only be set in one update step.
impulseX_ = 0.0;
impulseY_ = 0.0;
}