Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / How to calculate distance between two hex on hexagonal grid?

Author
Message
rymich
18
Years of Service
User Offline
Joined: 4th Jan 2007
Location:
Posted: 4th Jan 2007 15:15
Hello,

I am currently working on the turn base wargame, something like
Panzer general, and i have a trouble with calculating distance
between two hex, so i could move a unit according to units range.

Can anybody help?

Thx

Ps: I have already checked
- this forum
- Amits webpage
and havent found anything usefull so far.
Mystery Coffee Drinker
21
Years of Service
User Offline
Joined: 13th Sep 2003
Location: London
Posted: 4th Jan 2007 16:56
have another look at your hex grid, and think of it in terms of a normal square grid (with every other column slightly offset) it should be easier to use maths to get a distance from current hex to target hex.

Sorry I can't be more specific, but I haven't coded for a while, and not made any hex-based stuff for a lot longer!



M.C.D : P4 3.02 1gig DDR Radeon 9600 Windows XP Home
Finished Projects : Spellmaker (the old boardgame)
Current Project : RPG Crafting System
Suicidal Sledder
20
Years of Service
User Offline
Joined: 17th Aug 2004
Location: Tikrit, Iraq
Posted: 4th Jan 2007 18:46
If you mean real distance then just get the locations of both tiles and subtract. But if you mean distance as far as a count of tiles then I can't really help.

"See?!?! Port IS left and starboard is RIGHT!!" - Hobbes
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 4th Jan 2007 19:23
Check again on amit's pages
http://www-cs-students.stanford.edu/~amitp/Articles/Hexagon1.html Look for the section 'Hex counting for range'
http://www-cs-students.stanford.edu/~amitp/Articles/HexLOS.html (Check the bottom of the page in particular)

Login to post a reply

Server time is: 2025-06-25 09:18:02
Your offset time is: 2025-06-25 09:18:02