summaryrefslogtreecommitdiff
path: root/src/hitbox.rs
diff options
context:
space:
mode:
authorJustin Worthe <justin@worthe-it.co.za>2018-04-02 15:36:01 +0200
committerJustin Worthe <justin@worthe-it.co.za>2018-04-02 15:36:01 +0200
commit3b2017b7f4e7d1c932b430fa515286a9ceaf1a92 (patch)
tree59ea442f69a4428b9b4b00b1fcf16a0827a32524 /src/hitbox.rs
parenteba483718cdc46015a15ab14e5954e1468e209e3 (diff)
Added hitboxes and something for the bugs to run into
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()
+ }
+}