Hot answers tagged

5

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

All three uniform 2D grids can be stored in a rectangular grid, you just have to scale and shear it to fit the one you're aiming for. To know what regions you need to load just transform the viewport extents to the data's coordinate system.


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

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, ...


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 ...


1

If you are interested in doing a hex map you should definitely check out this http://www.redblobgames.com/grids/hexagons/ It coves few different methods of storing hex grids as well as basic operations like distance, fov, rotation and many more. It also describes how to do mapping from screen coordinates to hex coordinates and vice versa.


1

I've already answered a similar question, with identical goals, over on Stack Overflow I'll repost it here for convinience: (NB - all code is written and tested in Java) This image shows the top left corner of a hexagonal grid and overlaid is a blue square grid. It is easy to find which of the squares a point is inside and this would give a rough ...



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