summaryrefslogtreecommitdiff
path: root/src/entities/bug.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/entities/bug.rs
parenteba483718cdc46015a15ab14e5954e1468e209e3 (diff)
Added hitboxes and something for the bugs to run into
Diffstat (limited to 'src/entities/bug.rs')
-rw-r--r--src/entities/bug.rs15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/entities/bug.rs b/src/entities/bug.rs
index 424e195..482e5c4 100644
--- a/src/entities/bug.rs
+++ b/src/entities/bug.rs
@@ -1,5 +1,7 @@
use geometry::*;
+use hitbox::*;
+#[derive(Debug, Clone)]
pub struct Bug {
pub pos: Vec2d,
pub rotation: f64,
@@ -29,14 +31,13 @@ impl Bug {
};
self.pos = self.pos + delta_pos;
}
+}
- pub fn click(&mut self, point: Vec2d) {
- if self.touches(point) {
- self.alive = false;
- }
+impl CircleHitbox for Bug {
+ fn pos(&self) -> Vec2d {
+ self.pos
}
-
- fn touches(&self, point: Vec2d) -> bool {
- self.pos.distance(point) <= 75. // Some better hit box modelling might be nice?
+ fn radius(&self) -> f64 {
+ 75.
}
}