Jump to content
  • Advertisement
Sign in to follow this  
soiheardyoulike

A Hexagon Based Tile Map For Xna

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!