# Tag Info

7

While I don't know of any truly official convention for classifying these, in the mathematical sense, I'll take Anko's advice and write up what I do know... Amit Patel (Red Blob Games) wrote what I'd consider the definitive guide to using hexagonal grids in games. This guide uses the nomenclature: flat topped pointy topped So while it's not super ...

6

As Vector57 noted, the problem is you are using the wrong coordinate system. The algorithm described is meant to be used with cube coordinates, which have x, y and z components: This may not be obvious from the algorithm's pseudocode, but that's because it's a simplification of this: var results = [] for each -N ≤ dx ≤ N: for each -N ≤ dy ≤ N: ...

3

So upon further inspection your problem actually has nothing to do with coordinate system conversions. This could have been made more clear by not naming your axial coordinates X and Y but rather Q and R. The problem you're actually having is bad loop conditions. The original code sample produces delta q's and r's which you try to convert, in your for loops, ...

3

Try turning on the grid in Tiled (Ctrl+G) and adjusting your "Tile Side Length" in the Map Properties so that the grid matches correctly with your tiles. It may fix the libgdx rendering issue, and would improve the mouse picking in Tiled a little. I know setting up a hexagonal map (and even an isometric map) is somewhat confusing at the moment. It's ...

3

Quite honestly, I think you actually are over-thinking this. It's good to have a well thought-out design, but it's important not to get too hung up on the small details at an early stage. That being said, I think there is a fourth option here that might help you a bit: As opposed to filling in all hexagons that can be moved to, you can draw an outline ...

2

Amit Patel wrote a great entry all about hexagonal coordinate systems at http://www.redblobgames.com/grids/hexagons/ and I strongly encourage you to read through the whole thing for a deeper understanding. A system he mentions in there that happens to be my personal choice for such systems is the Cube Coordinate system; In this system, three numbers are ...

2

I think it'll be easier to solve this if you move one step at a time instead of one-or-two. For each location on the map there's a single direction to move in. Let's calculate that direction. First observation: if you're using the 3-valued “cube” coordinates, the largest coordinate tells you which of the six “wedges” you're in. Here's a diagram showing the ...

1

I would do it in two 1-cell steps instead of a single 2-cell step, it’s a lot easier to implement. Using your coding style, here would be my first try: var dx = 0, dy = 0; for (var i = 0, x = pos.x, y = pos.y; i < 2; ++i, x += dx, y += dy) { var z = x + y; // If point is on the edge, move along the edge if (x != 0 && y ==...

Only top voted, non community-wiki answers of a minimum length are eligible