updateTrajectory method

void updateTrajectory(
  1. Vector2 startPos,
  2. Vector2 velocity,
  3. double gravity
)

Implementation

void updateTrajectory(Vector2 startPos, Vector2 velocity, double gravity) {
  _points.clear();
  const int count = 20;
  const double step = 0.075;

  for (int i = 0; i < count; i++) {
    final t = i * step;
    _points.add(Vector2(
      startPos.x + velocity.x * t,
      startPos.y + velocity.y * t + 0.5 * gravity * t * t,
    ));
  }
}