-
Notifications
You must be signed in to change notification settings - Fork 0
/
tour.cpp
112 lines (92 loc) · 1.38 KB
/
tour.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#include "tour.h"
#include "Sprites.h"
#include <iostream>
Tour::Tour(RenderWindow &app, float posX, float posY) : Bloc(app, P_TOUR, posX, posY)
{
img->Draw();
Type = "Tour";
sellPrice = 500;
price = 1000;
pX = posX;
pY = posY;
strenght = 20;
shot = false;
es = 0;
rayon = 80;
mis = new Sprites(app);
}
Tour::~Tour()
{
delete mis;
}
void Tour::Do(vector<Ennemy*> &v, float gameTime)
{
if(this->GetVie() > 0)
{
if(!shot)
{
for(int i = 0; i < (signed)v.size(); i++)
{
if(v[i]->checkAlive() && isIn(v[i]->getPx(), v[i]->getPy()))
{
es = i;
shot = true;
break;
}
}
}
if(shot && isIn(v[es]->getPx(), v[es]->getPy()))
{
mis->shot(gameTime, *this, *v[es]);
if(!v[es]->checkAlive())
{
shot = false;
this->SetVie(this->GetVie() - 5);
}
}
else
{
shot = false;
}
}
else
{
shot = false;
}
}
float Tour::getPx()
{
return pX;
}
float Tour::getPy()
{
return pY;
}
int Tour::getPrice()
{
return price;
}
bool Tour::getShot()
{
return shot;
}
void Tour::setShot(bool c)
{
shot = c;
}
bool Tour::isIn(float x, float y)
{
float dist = ((x - pX) * (x - pX)) + ((y - pY) * (y - pY));
if(dist > (rayon * rayon))
return false;
else
return true;
/*if(((pX - 100) < x) && ((pX + 100) > x))
{
if(((pY - 100) < y) && ((pY + 100) > y))
{
return true;
}
}
return false;*/
}