summaryrefslogtreecommitdiff
path: root/src/entities/bug.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/entities/bug.rs')
-rw-r--r--src/entities/bug.rs12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/entities/bug.rs b/src/entities/bug.rs
index 6b39e8a..d2d5c2e 100644
--- a/src/entities/bug.rs
+++ b/src/entities/bug.rs
@@ -6,6 +6,8 @@ pub struct Bug {
pub alive: bool
}
+const SPEED: f64 = 75.;
+
impl Bug {
pub fn new(x: f64, y: f64, facing: f64) -> Bug {
Bug {
@@ -19,7 +21,13 @@ impl Bug {
}
pub fn advance(&mut self, seconds: f64) {
- //TODO, add some motion
+ self.rotation = (-self.pos).angle();
+ let distance = SPEED*seconds;
+ let delta_pos = Vec2d {
+ x: distance * self.rotation.cos(),
+ y: distance * self.rotation.sin()
+ };
+ self.pos = self.pos + delta_pos;
}
pub fn click(&mut self, point: Vec2d) {
@@ -29,6 +37,8 @@ impl Bug {
}
fn touches(&self, point: Vec2d) -> bool {
+ let rx = 35.;
+ let ry = 16.;
self.pos.distance(point) <= 45. // Some better hit box modelling might be nice?
}
}