mod coords; pub use coords::*;
mod map; pub use map::*;
#[derive(Clone, Copy, Debug)]
pub enum Orientation
{
PointyTop,
FlatTop,
}
impl Orientation
{
pub fn tile_width(&self) -> f32
{
match self {
Self::PointyTop => constants::POINTY_TOP_WIDTH,
Self::FlatTop => constants::FLAT_TOP_WIDTH,
}
}
pub fn tile_height(&self) -> f32
{
match self {
Self::PointyTop => constants::POINTY_TOP_HEIGHT,
Self::FlatTop => constants::FLAT_TOP_HEIGHT,
}
}
pub fn tile_spacing_x(&self) -> f32
{
match self {
Self::PointyTop => constants::POINTY_TOP_X_SPACING,
Self::FlatTop => constants::FLAT_TOP_X_SPACING,
}
}
pub fn tile_spacing_y(&self) -> f32
{
match self {
Self::PointyTop => constants::POINTY_TOP_Y_SPACING,
Self::FlatTop => constants::FLAT_TOP_Y_SPACING,
}
}
pub fn tile_corners(&self) -> [(f32, f32);6]
{
match self {
Self::PointyTop => constants::POINTY_TOP_CORNERS,
Self::FlatTop => constants::FLAT_TOP_CORNERS,
}
}
}
mod constants
{
pub const FLAT_TOP_HEIGHT: f32 = SQRT_3;
pub const FLAT_TOP_WIDTH: f32 = 2.0;
pub const FLAT_TOP_X_SPACING: f32 = FLAT_TOP_WIDTH * 3.0 / 4.0;
pub const FLAT_TOP_Y_SPACING: f32 = FLAT_TOP_HEIGHT;
pub const FLAT_TOP_CORNERS: [(f32, f32);6] = [
(-FLAT_TOP_WIDTH / 4.0, FLAT_TOP_HEIGHT / 2.0),
(FLAT_TOP_WIDTH / 4.0, FLAT_TOP_HEIGHT / 2.0),
(FLAT_TOP_WIDTH / 2.0, 0.0),
(FLAT_TOP_WIDTH / 4.0, -FLAT_TOP_HEIGHT / 2.0),
(-FLAT_TOP_WIDTH / 4.0, -FLAT_TOP_HEIGHT / 2.0),
(-FLAT_TOP_WIDTH / 2.0, 0.0),
];
pub const POINTY_TOP_HEIGHT: f32 = 2.0;
pub const POINTY_TOP_WIDTH: f32 = SQRT_3;
pub const POINTY_TOP_CORNERS: [(f32, f32);6] = [
(0.0, POINTY_TOP_HEIGHT / 2.0),
(POINTY_TOP_WIDTH / 2.0, POINTY_TOP_HEIGHT / 4.0),
(POINTY_TOP_WIDTH / 2.0, -POINTY_TOP_HEIGHT / 4.0),
(0.0, -POINTY_TOP_HEIGHT / 2.0),
(-POINTY_TOP_WIDTH / 2.0, -POINTY_TOP_HEIGHT / 4.0),
(-POINTY_TOP_WIDTH / 2.0, POINTY_TOP_HEIGHT / 4.0),
];
pub const POINTY_TOP_X_SPACING: f32 = POINTY_TOP_WIDTH;
pub const POINTY_TOP_Y_SPACING: f32 = POINTY_TOP_HEIGHT / 4.0 * 3.0;
const SQRT_3: f32 = 1.73205080757;
}