use geometry::*; use hitbox::*; #[derive(Debug, Clone)] pub struct Bug { pub pos: Vec2d, pub rotation: f64, pub alive: bool } const SPEED: f64 = 175.; 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; } } impl CircleHitbox for Bug { fn pos(&self) -> Vec2d { self.pos } fn radius(&self) -> f64 { 75. } }