-
Notifications
You must be signed in to change notification settings - Fork 0
/
explosion.cpp
31 lines (27 loc) · 992 Bytes
/
explosion.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include "explosion.h"
Explosion::Explosion(sf::Time tempsPassePrincipal, sf::Vector2f position, sf::Vector2u tailleVaisseau, unsigned int tailleExplosion, int vitesse)
{
m_etat = 0;
m_position.x = position.x - tailleExplosion / 2 + tailleVaisseau.x / 2;
m_position.y = position.y - tailleExplosion / 2 + tailleVaisseau.y / 2;
m_vitesse = vitesse;
m_tempsPasseEtat = tempsPassePrincipal;
m_tempsPasseAvancer = tempsPassePrincipal;
SoundManager::getInstance()->jouerSon(EXPLOSION);
}
Explosion::~Explosion()
{
}
void Explosion::changerEtat(sf::Time tempsPassePrincipal)
{
if((tempsPassePrincipal.asMilliseconds() - m_tempsPasseEtat.asMilliseconds()) >= 75)
{
m_etat++;
m_tempsPasseEtat = tempsPassePrincipal;
}
}
void Explosion::avancer(sf::Time tempsPassePrincipal)
{
m_position.y = m_position.y + m_vitesse * (tempsPassePrincipal.asSeconds() - m_tempsPasseAvancer.asSeconds());
m_tempsPasseAvancer = tempsPassePrincipal;
}