Hex maps....

BlitzMax Forums/BlitzMax Programming/Hex maps....

GfK(Posted 2009) [#1]
I'm toying with an idea for a game that wouldn't really be practical with a typical square map and would work a lot better with a hex map.

If I were to use square tiles I could just use a two-dimensional array. What's the accepted practice/structure for defining/storing hex maps?


Amon(Posted 2009) [#2]
It would be a bit like making a puzzle bobble game. What I did for that is just use a standard tilemap array but offset the draw position?

Still a 2d array but the tiles are offset when drawn which still allows for collision checking via the array.

Soz if it's not what you want.


GfK(Posted 2009) [#3]
What I did for that is just use a standard tilemap array but offset the draw position?
That's what I did for Buzzword but there has to be a better way?


Amon(Posted 2009) [#4]
Here's a gamedev.net article on the subject that might be usefull.

http://www.gamedev.net/reference/articles/article747.asp


Kanati(Posted 2009) [#5]
You know I've researched this subject a half dozen times over the last 5 years or so and never came up with anything that was clear and concise enough to figure out.

THAT article finally did it. It's clear, understandable, and concise. Awesome.


_Skully(Posted 2009) [#6]
That is a really great article.. I might be able to add Hex and Iso support to TileMax with that!


Bremer(Posted 2009) [#7]
Thanks for pointing to that article, its a really great article. And it looks like it would be a system that would work well for what GfK was asking for.


Garns(Posted 2009) [#8]
I've done some work on this in the past. I've created maps using hexagonal tiles or used pre-prepared maps or even just drawing the hexes using a series of nested FOR loops. The hardest thing I came across when I was just starting out, was not drawing the hexes, but actually converting the mouse coordinates to map coordinates.

I have a C# function that does just this that I could send through if you wanted it. I don't claim that it is the fastest function around, but it gets the job done. I also posted my function on gamedev.net in case anybody else was searching for a very basic solution.

If I could offer any advice, I would use either hexagonal tiles or pre-drawn maps. If you are doing a board game conversion, you can generally get good scans of maps from the games website. Pre-drawn maps are good and require much less work. Other good resources for tiles are the Cyberboard/VASSAL/Aide de Camp websites.

Cheers

Mark


JA2(Posted 2009) [#9]
My current project uses a hex map. Once you get your head around adding/subtracting values to take the offset into account then it's really not much more difficult than a standard square tile map.

I'm using 3d models for my game (based on Slay!) so the mouse coordinates aren't really an issue for me, just using the last picked hexagon works fine.


Czar Flavius(Posted 2009) [#10]
converting the mouse coordinates to map coordinates.
For my (isometric) game, I just had a 1 pixel by 1 pixel invisible image that I use to collision check at the mouse pointer's coordinates against the tiles. It works for me :D


GfK(Posted 2009) [#11]
Thanks for the input all - seems like my previous method was the correct one after all.

For my (isometric) game, I just had a 1 pixel by 1 pixel invisible image that I use to collision check at the mouse pointer's coordinates against the tiles. It works for me :D
You can use CollideRect() for the same effect without the requirement of a 1x1 image.