-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprojectile.cpp
More file actions
98 lines (89 loc) · 1.9 KB
/
Copy pathprojectile.cpp
File metadata and controls
98 lines (89 loc) · 1.9 KB
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
#include "projectile.h"
QPoint Projectile::getPointImpact() const
{
return pointImpact;
}
int Projectile::getTailleImpact()
{
return tailleImpact;
}
void Projectile::setTailleImpact(int value)
{
tailleImpact = value;
}
QPixmap *Projectile::getTexture() const
{
return texture;
}
void Projectile::setTexture(QPixmap *value)
{
texture = value;
}
Projectile::~Projectile()
{
delete texture;
}
Projectile::Projectile(QPoint point, int direction, int puissance)
{
//QPoint tmp(point.x() + (puissance*cos(direction)), point.y() + (puissance*sin(direction)));
//Ancienne version ou on pouvait tirer n'importe ou
//On imagine un cercle de rayon puissance avec pour centre le tank et on en extrait le point à l'angle direction
qDebug() << "Point d'origine du tir/ Position du tank : "<<point;
QPoint tmp = point;
int dx = 0, dy = 0;
switch (direction) {
case 0:
//haut
dx = 0; dy = -1;
break;
case -2:
//gauche
dx = -1; dy = 0;
break;
case 4:
//bas
dx = 0; dy = 1;
break;
case 2:
//droite
dx = 1; dy = 0;
break;
case -1:
//hautgauche
dx = -1; dy = -1;
break;
case -3:
//basgauche
dx = -1; dy = 1;
break;
case 1:
//hautdroite
dx = 1; dy = -1;
break;
case 3:
//basdroite
dx = 1; dy = 1;
break;
default:
break;
}
QPoint dir(dx, dy);
qDebug() << "Direction du projectile : "<<dir;
for(int i = 0; i<puissance; i++){
tmp += dir;
}
if(tmp.x()<0){
qDebug() << "Tir en dehors x";
pointImpact = QPoint(100, 100);
}
else{
pointImpact = tmp;
}
if(tmp.y()<0){
qDebug() << "Tir en dehors y";
pointImpact = QPoint(100, 100);
}
else{
pointImpact = tmp;
}
}