Hi,
I need to get my projectiles moving relevant to time. As well as sprite animation.
The code that I have for my bullets at the moment is as follows. They do not seem to animate with relevance to time. To be honest I am pretty baffled by this.
struct BulletData
{
sf::Vector2f direction;
sf::Vector2f startpos;
float speed;
bool active;
BulletData()
{
direction = sf::Vector2f(0.0f,0.0f);
startpos = sf::Vector2f(0.0f,0.0f);
speed = 600000.0f;
active = false;
}
};
sf::Time dt; // delta time
sf::Time elapsedTime;
sf::Clock clock;
elapsedTime += dt;
int timeAsMs = elapsedTime.asMilliseconds();
dt = clock.restart();
void Game::updateBulletCollisions(sf::Time dt)
{
for (int i = 0; i < NO_BULLETS; i++)
{
if (this->_arr_bullet_data[i].active)
{
sf::Vector2f tbulletvel = this->_arr_bullet_data[i].direction * this->_arr_bullet_data[i].speed * dt.asSeconds();
this->_arr_bullet_spr[i].move(tbulletvel);
}
}
Regards
Andy