forked from ArthyD/Bestioles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
BestioleGregaire.cpp
49 lines (41 loc) · 1.8 KB
/
BestioleGregaire.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include "BestioleGregaire.h"
BestioleGregaire::BestioleGregaire(void){}
// Fonction : BestioleGregaire
// Entrée : les attributs de la bestiole
// Action : Constructeur de la bestiole
BestioleGregaire::BestioleGregaire(bool pM, double t, int a, double champo, double disto, double distOr, double capaOeil, double capaOreille, double coeffCamou, double coeffCarap, double coeffDebuffCarap, double coeffNag){
identite = ++next;
cout << "Naissance Bestiole (" << identite << ") " << endl;
x = y = 0;
cumulX = cumulY = 0.;
orientation = static_cast<double>( rand() )/RAND_MAX*2.*M_PI;
vitesse = static_cast<double>( rand() )/RAND_MAX*MAX_VITESSE * (coeffNageoire / coeffDebuffCarapace);
couleur = new T[ 3 ];
couleur[ 0 ] = static_cast<int>( static_cast<double>( rand() )/RAND_MAX*230. );
couleur[ 1 ] = static_cast<int>( static_cast<double>( rand() )/RAND_MAX*230. );
couleur[ 2 ] = static_cast<int>( static_cast<double>( rand() )/RAND_MAX*230. );
persoMult = pM;
taille = t;
anneesRestantes = a;
champOeil = champo;
champOreille = 2*M_PI;
distanceOeil = disto;
distanceOreille = distOr;
capaciteOeil = capaOeil;
capaciteOreille = capaOreille;
coeffCamouflage = coeffCamou;
coeffCarapace = coeffCarap;
coeffDebuffCarapace = coeffDebuffCarap;
coeffNageoire = coeffNag;
}
BestioleGregaire::~BestioleGregaire(){};
void BestioleGregaire::update(vector<std::shared_ptr<Bestiole>>& vectorBestioleProche){
double moyenne = 0;
if(vectorBestioleProche.size() !=0){
for (std::vector<std::shared_ptr<Bestiole>>::iterator it = vectorBestioleProche.begin() ; it != vectorBestioleProche.end() ; it++){
moyenne += (*it)->getOrientation();
}
moyenne = moyenne/vectorBestioleProche.size();
orientation = moyenne;
}
}