use crate::{
geom::*,
models::{BulletState, BULLET_SPEED},
};
#[derive(Debug)]
pub struct Bullet {
pub id: u32,
pub position: Point,
pub velocity: Vector,
pub player_id: u32,
}
impl Bullet {
pub fn new(state: &BulletState) -> Self {
Bullet {
id: state.id,
position: Point::new(state.x, state.y),
velocity: Vector::with_angle(Radian::new(state.angle)) * BULLET_SPEED,
player_id: state.player_id,
}
}
}
impl PointExt for Bullet {
fn point(&self) -> &Point {
&self.position
}
}
impl VectorExt for Bullet {
fn vector(&self) -> &Vector {
&self.velocity
}
}
impl Moving for Bullet {}