diff options
author | Mavridis Philippe <mavridisf@gmail.com> | 2024-08-07 19:13:02 +0300 |
---|---|---|
committer | Mavridis Philippe <mavridisf@gmail.com> | 2024-08-07 19:23:24 +0300 |
commit | 04b5a62b8d9f5ff8240f25361046f2a5d58e8262 (patch) | |
tree | 98b126454cdf68d544e138d7e8b31d5fd45b72c2 /kue/circle.h | |
parent | 83ba00b7e569587d50383ff06a70148042ca780e (diff) | |
download | tdegames-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/circle.h')
-rw-r--r-- | kue/circle.h | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/kue/circle.h b/kue/circle.h new file mode 100644 index 00000000..d412b41d --- /dev/null +++ b/kue/circle.h @@ -0,0 +1,27 @@ +#ifndef _CIRCLE_H +#define _CIRCLE_H + +#include "point.h" + +// Billards and pockets are both circles +// The collison detection code likes to deal with circles, not billards and pockets + +class circle : public point { + public: + circle(double x, double y, double r) : point(x, y) { _radius = r; } + ~circle() {} + + // Accessors + double radius() { return _radius; } + void setRadius(double radius) { _radius = radius; } + + // Returns true if we intersect the other circle + double intersects(const circle &other_circle) { return (distance(other_circle) - other_circle._radius) <= _radius; } + // Returns the distance from the edge of this circle to the edge of the other + double edgeDistance(const circle &other_circle) { return distance(other_circle) - _radius - other_circle._radius; } + + protected: + double _radius; +}; + +#endif |