Galactica/src/ship.rs
2023-12-22 21:39:47 -08:00

41 lines
606 B
Rust

use cgmath::Point2;
use crate::{physics::Pfloat, physics::PhysBody, Sprite, Spriteable};
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: Point2<Pfloat>) -> Self {
Ship {
body: PhysBody::new(pos),
kind,
}
}
}
impl Spriteable for Ship {
fn sprite(&self) -> Sprite {
return Sprite {
pos: self.body.pos,
name: self.kind.sprite().to_owned(),
angle: self.body.angle,
scale: 1.0,
};
}
}