update method

Vec2 update(
  1. double dt,
  2. Vec2 target
)

Implementation

Vec2 update(double dt, Vec2 target) {
  _force
    ..setFrom(target)
    ..sub(pos)
    ..scale(stiffness);

  _force.x -= velocity.x * damping;
  _force.y -= velocity.y * damping;

  velocity.x += _force.x * dt;
  velocity.y += _force.y * dt;

  pos.x += velocity.x * dt;
  pos.y += velocity.y * dt;

  return pos;
}