summaryrefslogtreecommitdiffstats
path: root/kue/point.cpp
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.cpp
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.cpp')
-rw-r--r--kue/point.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/kue/point.cpp b/kue/point.cpp
new file mode 100644
index 00000000..3ee12888
--- /dev/null
+++ b/kue/point.cpp
@@ -0,0 +1,19 @@
+#include "point.h"
+#include <math.h>
+
+point::point(double x, double y) {
+ _pos_x = x;
+ _pos_y = y;
+}
+
+point::~point() {
+}
+
+double point::distance(const point &other_point) const {
+ // Finds the distance between two points, using:
+ // d^2 = (x1 - x2)^2 + (y1 - y2)^2
+ double delta_x = _pos_x - other_point._pos_x;
+ double delta_y = _pos_y - other_point._pos_y;
+
+ return sqrt((delta_x * delta_x) + (delta_y * delta_y));
+}