-
Notifications
You must be signed in to change notification settings - Fork 2
/
check_damage.cpp
56 lines (53 loc) · 1.03 KB
/
check_damage.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
#include <iostream>
#include <cmath>
#include <vector>
using namespace std;
/* NOT ACTUALLY USED */
struct Rect
{
int x;
int y;
int width;
int height;
};
struct Tuple
{
double x;
double y;
};
struct Player
{
Tuple pos;
int health;
};
vector<Player> check_damage(vector<vector<double> > bullets, vector<Player> players) {
vector<Player> damaged = players;
for (auto const& b: bullets) {
for (int p = 0; p < players.size(); p++) {
double lx = b[0];
double ly = b[1];
double angle = b[2] * 3.1415926535 / 180;
for (int i = 0; i < 20; i++) {
double ix = lx + i * cos(angle);
double iy = ly + i * sin(angle);
if (hypot(ix+lx, iy+ly) < 20) {
damaged[p].health -= 10;
cout << "Damage Taken" << endl;
}
}
}
}
return damaged;
}
int main() {
vector<vector<double> > shotgun{
{644, 689, 45},
{7, 7, 78}
};
vector<Player> gamers{
{10, 10, 100},
{8, 8, 100},
{5, 5, 100},
};
check_damage(shotgun, gamers);
}