-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Offset is not applying to pointy hex when using distance method #109
Comments
Thanks for opening the issue. I'll look into it next week at the earliest. |
I don't see how the distance between hexes in a grid is affected by the hex offset setting. And I couldn't find anything related to that on the redblobgames.com website. Do you have a link that explains the expected behavior? |
Yes of course, look this link (https://www.redblobgames.com/grids/hexagons/) Distance are different in the Coordinate Systems -> offset coordinates-> (pointed odd r and pointed even r) have different distances from 3,1 to 4,2. |
HI flauwekeul , could you check it? |
I will, sorry for the silence. I was able to reproduce the problem. My free time is very limited, but I'll try to look into it this year. Thanks for your patience. |
got it working with this:
|
i dunno if this is useful, but I used offset [1,1] and the distances were calculated correctly. const size = 40; const Hex = defineHex({ |
Describe the bug
Offset is not applying to pointy hex when using grid distance method
To Reproduce
const WideHex = defineHex({
dimensions: { xRadius: 50, yRadius: 30 }, // wide hexes
offset: -1, // or 1
})
const distanceCalculator = new Grid(WideHex, rectangle({ width: 10, height: 10 }))
console.log(
Starting coordinates:${boardTile.x},${boardTile.y}
,Destination coordinates:${qBoardCoordinate},${rBoardCoordinate}
,Distance:${distanceCalculator.distance( [boardTile.x, boardTile.y], [qBoardCoordinate, rBoardCoordinate] )}
,distanceCalculator.toJSON(),
)
// Case 1
// Case 2
Expected behavior
When changing offset one of them should calculate 1 and the other 2, as distance as seen in redblob blog.
Environment (please complete the following information):
Screenshots
Not apply
Additional context
Not for the moment
The text was updated successfully, but these errors were encountered: