diff --git a/src/common/Shot.cc b/src/common/Shot.cc index 1b2f1c2..763bde4 100644 --- a/src/common/Shot.cc +++ b/src/common/Shot.cc @@ -44,8 +44,9 @@ Shot::Shot(const Vector2f & origin, double direction, double target_dist) / (2 * t * GRAVITY); } -Vector3f Shot::get_pos_at_time(double time) +Vector3f Shot::get_position() { + float time = m_clock.getElapsedTime().asSeconds(); float horiz_dist = m_speed * time; float z = INITIAL_SHOT_HEIGHT + m_speed * time - GRAVITY * time * time / 2.0; Vector2f xy = m_direction * horiz_dist; diff --git a/src/common/Shot.h b/src/common/Shot.h index 5421351..f70dbc7 100644 --- a/src/common/Shot.h +++ b/src/common/Shot.h @@ -8,11 +8,12 @@ class Shot { public: Shot(const sf::Vector2f & origin, double direction, double target_dist); - sf::Vector3f get_pos_at_time(double time); + sf::Vector3f get_position(); protected: sf::Vector2f m_origin; sf::Vector2f m_direction; double m_speed; + sf::Clock m_clock; }; #endif