use geometry::*; pub struct Bug { pub pos: Vec2d, pub rotation: f64, pub alive: bool } const SPEED: f64 = 75.; 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) { 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) { if self.touches(point) { self.alive = false; } } fn touches(&self, point: Vec2d) -> bool { self.pos.distance(point) <= 75. // Some better hit box modelling might be nice? } }