use geometry::*; use hitbox::*; use asset_id::*; #[derive(Clone)] pub struct Home { pub pos: Vec2d, pub animation_time: f64, pub sprite: SpriteId } impl Home { pub fn new(x: f64, y: f64) -> Home { Home { pos: Vec2d::new(x, y), animation_time: 0., sprite: SpriteId::Sleepypug1 } } pub fn advance(&mut self, seconds: f64) { let scale = 0.5; self.animation_time = (self.animation_time + scale * seconds).fract(); self.sprite = if self.animation_time < 0.3 { SpriteId::Sleepypug1 } else if self.animation_time < 0.4 { SpriteId::Sleepypug2 } else if self.animation_time < 0.5 { SpriteId::Sleepypug3 } else if self.animation_time < 0.8 { SpriteId::Sleepypug4 } else if self.animation_time < 0.9 { SpriteId::Sleepypug3 } else { SpriteId::Sleepypug2 } ; } pub fn hitbox(&self) -> Hitbox { Hitbox::Circle(CircleHitbox{ pos: self.pos, radius: 100. }) } }