generated from tipragot/rust
add "distance_to" fonction
This commit is contained in:
parent
99489a46a1
commit
1fc89b08da
|
@ -35,8 +35,10 @@ pub struct HexPosition {
|
|||
impl HexPosition {
|
||||
/// Returns the distance between two "HexPosition"
|
||||
pub fn distance_to(&self, other: &HexPosition) -> f32 {
|
||||
|
||||
1.
|
||||
((self.q - other.q).abs()
|
||||
+ (self.r - other.r).abs()
|
||||
+ (self.q + self.r - other.q - other.r).abs()) as f32
|
||||
/ 2.
|
||||
}
|
||||
|
||||
/// Returns all positions in a given range
|
||||
|
|
Loading…
Reference in a new issue