1
\$\begingroup\$

So I made a hexagonal tilemap of ocean tiles and then picked a few tiles to be land. When I pick all adjacent tiles to the hexagon it usually works, but for tiles that are on certain columns it does not. Also, on these columns the tops and bottoms of tiles are missing.

It's hard to explain but here's a screenshot that should clear it up:

enter image description here

As you can see, on every other column the top and bottom of hexagons are missing, when all adjacent tiles are filled in to the centre tile it works fine for those columns without a bottom and top on hex, but when it's on the other column one of the adjacent tiles is displaced.

Any suggestions?

Code:

    baseLayer.setCell((int)islands[currentTile].x , (int)islands[currentTile].y, landCell);

    baseLayer.setCell((int)islands[currentTile].x + 1, (int)islands[currentTile].y + 1, landCell);

    baseLayer.setCell((int)islands[currentTile].x + 1, (int)islands[currentTile].y, landCell);

    baseLayer.setCell((int)islands[currentTile].x , (int)islands[currentTile].y - 1, landCell);

    baseLayer.setCell((int)islands[currentTile].x - 1, (int)islands[currentTile].y, landCell);

    baseLayer.setCell((int)islands[currentTile].x , (int)islands[currentTile].y + 1, landCell);

    baseLayer.setCell((int)islands[currentTile].x - 1, (int)islands[currentTile].y + 1, landCell);
\$\endgroup\$
10
  • \$\begingroup\$ What are you using to render the hexagons? \$\endgroup\$
    – Elva
    Commented Nov 20, 2015 at 16:16
  • \$\begingroup\$ @Kevin van der Velden HexagonalTiledMapRenderer \$\endgroup\$ Commented Nov 20, 2015 at 16:21
  • \$\begingroup\$ Does this solve your problem? gamedev.stackexchange.com/questions/106640/… \$\endgroup\$
    – Elva
    Commented Nov 20, 2015 at 16:26
  • 1
    \$\begingroup\$ You have a rounding error occurring. Check your pixel placement values carefully for both odd and even columns of hexes. I encountered the same problem with my game, and it took a little finagling of the numbers to get everything lined up. If you draw zoomed instead of zooming the drawing you will encounter the same problem gain at certain zoom leves. \$\endgroup\$ Commented Nov 20, 2015 at 17:20
  • 1
    \$\begingroup\$ @TheMagicShroom I'm guessing your code for adjacent tiles is for axial coordinates and not the staggered/offset system. If you test some more and find that the code works properly for even columns but not odd (or vice versa) then that would be the issue. I have an article that shows pseudocode for finding the adjacent hexes. \$\endgroup\$
    – amitp
    Commented Nov 20, 2015 at 22:33

0

You must log in to answer this question.

Browse other questions tagged .