From b528c6adbe8805010476175e448bd5db2b462493 Mon Sep 17 00:00:00 2001 From: dani Date: Thu, 6 Jul 2023 14:41:36 +0000 Subject: [PATCH] idx_size and cood_to_idx --- src/hexmap.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/hexmap.rs b/src/hexmap.rs index 1d7dcad..5ae2550 100644 --- a/src/hexmap.rs +++ b/src/hexmap.rs @@ -82,6 +82,10 @@ impl HexMap { Vec2 { x, y } } + fn coord_to_idx(&self, coord: Vec2) -> usize { + (coord.x + coord.y * self.size.x) as usize + } + pub fn coord_to_pixel(&self, coord: Vec2) -> Vec2 { Vec2 { x: coord.x * self.pix_tile_off.x, @@ -110,6 +114,10 @@ impl HexMap { self.size } + pub fn idx_size(&self) -> usize { + self.size.size() + } + //pubcrate pub(crate) fn draw_tile_to_image( &self, @@ -122,11 +130,6 @@ impl HexMap { self.tileset.get(self.data[self.coord_to_idx(coord)]), ) } - - //priv - fn coord_to_idx(&self, coord: Vec2) -> usize { - (coord.x + coord.y * self.size.x) as usize - } } impl Distribution for Standard {