File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java Micro Edition and the fly likes Mapping a hex game board to rectangular tiles. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » Java Micro Edition
Bookmark "Mapping a hex game board to rectangular tiles." Watch "Mapping a hex game board to rectangular tiles." New topic

Mapping a hex game board to rectangular tiles.

Burk Hufnagel
Ranch Hand

Joined: Oct 01, 2001
Posts: 814
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.

SCJP, SCJD, SCEA 5 "Any sufficiently analyzed magic is indistinguishable from science!" Agatha Heterodyne (Girl Genius)
Burk Hufnagel
Ranch Hand

Joined: Oct 01, 2001
Posts: 814
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

Joined: Mar 07, 2003
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

Joined: Mar 22, 2000
Posts: 13037
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.
I agree. Here's the link:
subject: Mapping a hex game board to rectangular tiles.
It's not a secret anymore!