summaryrefslogtreecommitdiff
path: root/src/hitbox.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/hitbox.rs')
-rw-r--r--src/hitbox.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/hitbox.rs b/src/hitbox.rs
new file mode 100644
index 0000000..df87b68
--- /dev/null
+++ b/src/hitbox.rs
@@ -0,0 +1,14 @@
+use geometry::*;
+
+pub trait CircleHitbox {
+ fn pos(&self) -> Vec2d;
+ fn radius(&self) -> f64;
+
+ fn touches_point(&self, point: Vec2d) -> bool {
+ self.pos().distance(point) <= self.radius()
+ }
+
+ fn touches_circle(&self, other: &CircleHitbox) -> bool {
+ self.pos().distance(other.pos()) <= self.radius() + other.radius()
+ }
+}