summaryrefslogtreecommitdiffstats
path: root/kue/point.h
diff options
context:
space:
mode:
authorMavridis Philippe <mavridisf@gmail.com>2024-08-07 19:13:02 +0300
committerMavridis Philippe <mavridisf@gmail.com>2024-08-07 19:23:24 +0300
commit04b5a62b8d9f5ff8240f25361046f2a5d58e8262 (patch)
tree98b126454cdf68d544e138d7e8b31d5fd45b72c2 /kue/point.h
parent83ba00b7e569587d50383ff06a70148042ca780e (diff)
downloadtdegames-feat/kue.tar.gz
tdegames-feat/kue.zip
Add Kue billiards gamefeat/kue
Signed-off-by: Mavridis Philippe <mavridisf@gmail.com>
Diffstat (limited to 'kue/point.h')
-rw-r--r--kue/point.h32
1 files changed, 32 insertions, 0 deletions
diff --git a/kue/point.h b/kue/point.h
new file mode 100644
index 00000000..c748e7d3
--- /dev/null
+++ b/kue/point.h
@@ -0,0 +1,32 @@
+#ifndef _POINT_H
+#define _POINT_H
+
+#include <math.h>
+
+// Point is just a point on a 2D plane
+class point {
+ public:
+ point(double x = 0.0, double y = 0.0);
+ ~point();
+
+ // Gets our position
+ double positionX() const { return _pos_x; }
+ double positionY() const { return _pos_y; }
+
+ // Sets our position
+ void setPositionX(double new_pos) {_pos_x = new_pos;}
+ void setPositionY(double new_pos) {_pos_y = new_pos;}
+ void setPosition(double new_x, double new_y) {_pos_x = new_x; _pos_y = new_y; }
+ void setPosition(const point &p) {_pos_x = p._pos_x; _pos_y = p._pos_y; }
+
+ // Finds the distance between us and another point
+ double distance(const point &other_point) const;
+ // Finds the angle between us and another point
+ double angle(const point &other_point) const { return atan2(other_point._pos_y - _pos_y, other_point._pos_x - _pos_x); }
+
+ protected:
+ double _pos_x;
+ double _pos_y;
+};
+
+#endif