-
Notifications
You must be signed in to change notification settings - Fork 0
/
tir.cpp
28 lines (24 loc) · 915 Bytes
/
tir.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
#include "tir.h"
Tir::Tir(sf::Time tempsPassePrincipal, bool ennemi, int vitesseVaisseau, sf::Vector2f position, sf::Vector2u tailleVaisseau, sf::Vector2u m_tailleTir)
{
m_ennemi = ennemi;
m_vitesse = vitesseVaisseau * 2;
m_position.x = position.x + tailleVaisseau.x / 2 - m_tailleTir.x / 2;
m_position.y = position.y + tailleVaisseau.y / 2;
m_tempsPasseAvancer = tempsPassePrincipal;
if(!m_ennemi) SoundManager::getInstance()->jouerSon(TIR);
}
Tir::~Tir()
{
}
void Tir::avancer(sf::Time tempsPassePrincipal)
{
if(m_ennemi)
{
m_position.y = m_position.y + m_vitesse * (tempsPassePrincipal.asSeconds() - m_tempsPasseAvancer.asSeconds());
m_tempsPasseAvancer = tempsPassePrincipal;
}else{
m_position.y = m_position.y - 600 * (tempsPassePrincipal.asSeconds() - m_tempsPasseAvancer.asSeconds());
m_tempsPasseAvancer = tempsPassePrincipal;
}
}