Shots keep track of their launch time

This commit is contained in:
josh committed 2012-10-06 21:27:55 -04:00
1 parent 3237d4e0e6
commit 1ceacd913d
2 files changed
+4 -2

No files matched your search

+2 -1
View File
@@ -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;
+2 -1
View File
@@ -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