idx_size and cood_to_idx

This commit is contained in:
dani 2023-07-06 14:41:36 +00:00
parent c18b32660a
commit b528c6adbe
1 changed files with 8 additions and 5 deletions

View File

@ -82,6 +82,10 @@ impl HexMap {
Vec2 { x, y } Vec2 { x, y }
} }
fn coord_to_idx(&self, coord: Vec2<i32>) -> usize {
(coord.x + coord.y * self.size.x) as usize
}
pub fn coord_to_pixel(&self, coord: Vec2<i32>) -> Vec2<i32> { pub fn coord_to_pixel(&self, coord: Vec2<i32>) -> Vec2<i32> {
Vec2 { Vec2 {
x: coord.x * self.pix_tile_off.x, x: coord.x * self.pix_tile_off.x,
@ -110,6 +114,10 @@ impl HexMap {
self.size self.size
} }
pub fn idx_size(&self) -> usize {
self.size.size()
}
//pubcrate //pubcrate
pub(crate) fn draw_tile_to_image( pub(crate) fn draw_tile_to_image(
&self, &self,
@ -122,11 +130,6 @@ impl HexMap {
self.tileset.get(self.data[self.coord_to_idx(coord)]), self.tileset.get(self.data[self.coord_to_idx(coord)]),
) )
} }
//priv
fn coord_to_idx(&self, coord: Vec2<i32>) -> usize {
(coord.x + coord.y * self.size.x) as usize
}
} }
impl Distribution<Direction> for Standard { impl Distribution<Direction> for Standard {