-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathball.h
More file actions
65 lines (52 loc) · 1.32 KB
/
ball.h
File metadata and controls
65 lines (52 loc) · 1.32 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
#ifndef BALL_H
#define BALL_H
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <stdlib.h>
#include <cmath>
using namespace cv;
class Ball {
public:
Ball(int width, int height, int rad, int x, int y, Vec2f vel, const Scalar& col) :
cam_width{width}, cam_height{height}, radius{rad},
position{Point(x,y)}, velocity{vel}, color{col} {}
// Update ball physics
void Update();
// Draw ball at Point(x,y) position with Scalar(r,g,b) colors on image
void Draw(Mat* image);
// Reset velocity, and the position to the center of frame
// LEFT = 0, NONE = 1, RIGHT = 2
void Reset(int side);
// Set Position
void SetPosition(int x, int y) {
position = Point(x,y);
}
// Get Position
Point GetPosition() const{
return position;
}
// Set Velocity
void SetVelocity(float x, float y) {
velocity = {x,y};
}
// Get Velocity
Vec2f GetVelocity() {
return velocity;
}
// Get Radius
int GetRadius() const {
return radius;
}
// Get if out of bounds
bool GetOutOfBounds() {
return out_of_bounds;
}
private:
int cam_width, cam_height;
Point position;
Vec2f velocity;
Scalar color;
int radius;
bool out_of_bounds = false;
};
#endif