use glam::Vec2;
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct MapInfo {
pub width: u32,
pub height: u32,
pub resolution: f32,
pub origin: Vec2,
}
impl Default for MapInfo {
fn default() -> Self {
Self {
width: 100,
height: 100,
resolution: 0.05,
origin: Vec2::ZERO,
}
}
}
impl MapInfo {
pub fn square(width: u32, resolution: f32) -> Self {
Self {
width,
height: width,
resolution,
..Default::default()
}
}
#[inline]
pub fn world_width(&self) -> f32 {
self.width as f32 * self.resolution
}
#[inline]
pub fn world_height(&self) -> f32 {
self.height as f32 * self.resolution
}
#[inline]
pub fn world_center(&self) -> Vec2 {
self.origin + Vec2::new(0.5 * self.world_width(), 0.5 * self.world_height())
}
}