Shots keep track of their launch time
This commit is contained in:
parent
3237d4e0e6
commit
1ceacd913d
@ -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;
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user