forked from wsu-lug/lug-fishtank
-
Notifications
You must be signed in to change notification settings - Fork 0
/
NearbyDetector.hpp
46 lines (37 loc) · 1.32 KB
/
NearbyDetector.hpp
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
#include "Fish.hpp"
class NearbyDetector {
private:
std::vector<std::shared_ptr<PriDrawable> > * draws;
int width;
int height;
public:
NearbyDetector(std::vector<std::shared_ptr<PriDrawable> > * drawables, int screen_width, int screen_height) {
draws = drawables;
height = screen_height;
width = screen_width;
}
Vector2D pickRandomPointInScreen(void) {
std::random_device rd;
std::mt19937 e2(rd());
std::uniform_int_distribution<int> dist((int)(width * 0.1), (int)(width * 0.9));
Vector2D thePoint;
thePoint.x = dist(e2);
dist = std::uniform_int_distribution<int>((int)(height * 0.1), (int)(height * 0.9));
thePoint.y = dist(e2);
return thePoint;
}
bool pointsClose(Vector2D point1, Vector2D point2) {
if(abs((point1.x - point2.x)) < width * 0.1 && abs(point1.y - point2.y)) {
return true;
}
}
void detect() {
std::queue<std::shared_ptr<PriDrawable> > things = std::queue<std::shared_ptr<PriDrawable> >();
Vector2D thePoint = pickRandomPointInScreen();
for(int i = 0; i < draws->size(); i++) {
if((*draws)[i]->isClose(thePoint)) {
things.push((*draws)[i]);
}
}
}
};