use crate::physics::Cartesian; use crate::physics::PhysBody; use crate::Camera; use crate::Sprite; pub enum ShipKind { Gypsum, } impl ShipKind { fn sprite(&self) -> &'static str { match self { Self::Gypsum => "gypsum", } } } pub struct Ship { pub body: PhysBody, kind: ShipKind, } impl Ship { pub fn new(kind: ShipKind, pos: Cartesian) -> Self { Ship { body: PhysBody::new(pos), kind, } } pub fn sprite(&self, camera: &Camera) -> Sprite { let p = self.body.pos - camera.pos; return Sprite { position: (p.x, p.y), name: self.kind.sprite().to_owned(), angle: self.body.angle as f32, }; } }