• 11
• 27
• 9
• 20
• 31

A Hexagon Based Tile Map For Xna

This topic is 2622 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

After a couple of tries i decided it would be best to use hexagons instead squares for a small point and click strategy game with xna. The hexagon fixes the diagonal issue and seems pretty nice. My current question is this how would you implement one? I have worked mainly with square files and would use a 2d array with characters in it, to represent each tile. I did this so i could make roads and crude lakes. How would you use a 2d array like this

{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
{2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2},
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}

to create the hexagon map? I read up on it and it seems that you need the exact pixels of the picture(the hexagon) so you can place them correctly. Or is my implementation not the correct way to go about hexagons

thanks

also i found some links to gamedev.net that appear to not be working. will there be a time when most of the website will come back on in terms of older content.
http://www.samugames.com/press/index.html

Share on other sites
You can store your data in exactly the same way. Just indent every odd row (or column, depending on the hexagons orientation) when displaying your tiles. Imagine that each [] is a hexagon:
[font="Courier New"][][][][] [][][][] [][][][] [][][][]
[font="Arial"]Of course, hexagonal tile images will differ from square ones. Hexagonal ones will have some empty space at the corners, so you should reduce the vertical distance between rows somewhat to take that into account. Exactly how much depends on how high these empty corners are, and that's up to you to decide. 2:1 edges usually work well in pixel art, so if a tile is 64x64, then it'll have a 32x16 empty triangle at every corner, so each next row should be draw 48 ( = 64 - 16) pixels below the previous one.[/font]
[/font]

Share on other sites
You might save yourself a headache by using square tiles and implementing the diagonal move as a combination horizontal/linear move.

[1][2]
[3][4]

If I am in tile 3, and I want to go to 2, you could do the following: Move right to 4, move up to 2. Or: Move up to 1, move right to 2.