Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!

# Mapping a hex game board to rectangular tiles.

Burk Hufnagel
Ranch Hand
Posts: 814
3
I was pleased to read about the Game APIs support of tiled screens, but I'm still stuck trying to figure out an efficient way to create a hexagon based map using rectangular tiles.
I started to explain a lot of the details, but for now I think just being able to make the map would be a good start.
Basically there's two types of hexes on the map. However, there's an added complication that any or all of the six sides of the hex could allow any game piece to cross or restrict crossing to specified types of pieces.
If anyone here's got experience with this kind of issue, or can point me in a reasonable direction, I'd be most grateful.
Thaks!

Burk Hufnagel
Ranch Hand
Posts: 814
3
Hmm... Nobody's replied which leads me to believe its either much simpler than I suspect, much harder, or nobody cares...
Guess I'd better try someplace like Gamasutra...

John Hembree
hired gun
Ranch Hand
Posts: 250
Sorry Burk, I've read your post but have no clue what to tell you. It's hard to tell how many people look at your post and then like myself don't have a clue. I actually came back in here when I saw that it had a reply to see what the answer might have been.

William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13061
6
It was quite a while ago and in a different environment but here is what I did.
The map was represented by multiple 2D arrays.
One array had "connectivity type code" for each location - this code controlled the allowable "movement" from that location in terms of the changes in x (rows) and y(columns) that were possible.
In other words, taking location x1,y1 the connectivity code led to all the legal changes in x and y - similiar to a terrain map really.
For display, each row has an offset that lets you display the row so it looks like a hex map.
(lets see if I can show this...)

So x1y1 is a type that can move +1x or +1y
x2y2 can move in six directions, etc.
Bill