summaryrefslogtreecommitdiff
path: root/src/entities/bug.rs
diff options
context:
space:
mode:
authorJustin Worthe <justin@worthe-it.co.za>2018-03-02 20:35:40 +0200
committerJustin Worthe <justin@worthe-it.co.za>2018-03-02 20:35:40 +0200
commit30df4064646fb429568474c0cdb2ee2ee08fd22e (patch)
tree2f444247ef993f2f3a346af747199cec3f2b9b46 /src/entities/bug.rs
parente1ba5ff36cefd602e64210dcfd0c4076c871e38c (diff)
Clickable bugs!
Diffstat (limited to 'src/entities/bug.rs')
-rw-r--r--src/entities/bug.rs34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/entities/bug.rs b/src/entities/bug.rs
new file mode 100644
index 0000000..6b39e8a
--- /dev/null
+++ b/src/entities/bug.rs
@@ -0,0 +1,34 @@
+use geometry::*;
+
+pub struct Bug {
+ pub pos: Vec2d,
+ pub rotation: f64,
+ pub alive: bool
+}
+
+impl Bug {
+ pub fn new(x: f64, y: f64, facing: f64) -> Bug {
+ Bug {
+ pos: Vec2d {
+ x: x,
+ y: y
+ },
+ rotation: facing,
+ alive: true
+ }
+ }
+
+ pub fn advance(&mut self, seconds: f64) {
+ //TODO, add some motion
+ }
+
+ pub fn click(&mut self, point: Vec2d) {
+ if self.touches(point) {
+ self.alive = false;
+ }
+ }
+
+ fn touches(&self, point: Vec2d) -> bool {
+ self.pos.distance(point) <= 45. // Some better hit box modelling might be nice?
+ }
+}