Timeline for How do I get pixel to hex coordinates on an array based hex map?
Current License: CC BY-SA 3.0
3 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Aug 21, 2013 at 20:23 | comment | added | amitp |
This is a reasonable approach. You can speed it up by scanning a smaller range of rows/cols instead of scanning all of them. To do this you need a rough idea of where the hex is. Since you're using offset grids, you can get a rough guess by dividing x by the spacing between columns and dividing y by the spacing between rows. Then instead of scanning all columns 0…cols-1 and all rows 0…rows-1, you can scan col_guess - 1 … col_guess+1 and row_guess - 1 … row_guess + 1. That's only 9 hexes so it's fast and not dependent on the size of the map.
|
|
| Aug 21, 2013 at 19:36 | history | edited | petervaz | CC BY-SA 3.0 |
deleted 2 characters in body
|
| Aug 21, 2013 at 16:00 | history | answered | petervaz | CC BY-SA 3.0 |