-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTarget.cpp
More file actions
54 lines (38 loc) · 942 Bytes
/
Target.cpp
File metadata and controls
54 lines (38 loc) · 942 Bytes
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
#include "Target.h"
/*
For now at least:
values for distances are in feet
values for time are in seconds
the world will be centered around the point (0,0)
*/
Target::Target() : totalTimeElapsed(0) {
currentPos = Vector2D(0, 0);
initialPos = Vector2D(0, 0);
};
Target::Target(double xStart, double yStart) : totalTimeElapsed(0) {
initialPos = Vector2D(xStart, yStart);
currentPos = initialPos;
m_isBroken = false;
};
Vector2D Target::currentPosition() const {
return currentPos;
}
void Target::update(double dtime) {
currentPos = position(totalTimeElapsed);
totalTimeElapsed += dtime;
}
bool Target::isBroken() {
return m_isBroken;
}
void Target::breakTarget() {
m_isBroken = true;
}
std::vector<Vector2D> Target::flightpath(double start, double end, double step) const{
std::vector<Vector2D> path;
double time = start;
do {
path.push_back(position(time));
time += step;
} while (time <= end);
return path;
}