summaryrefslogtreecommitdiff
path: root/src/entities
diff options
context:
space:
mode:
Diffstat (limited to 'src/entities')
-rw-r--r--src/entities/bug.rs34
-rw-r--r--src/entities/mod.rs1
2 files changed, 35 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?
+ }
+}
diff --git a/src/entities/mod.rs b/src/entities/mod.rs
new file mode 100644
index 0000000..0f4281c
--- /dev/null
+++ b/src/entities/mod.rs
@@ -0,0 +1 @@
+pub mod bug;