PDA

View Full Version : Cocoa Hex Based Game question


akinnie
2002.06.06, 08:51 AM
I'm porting a boardgame to computer and need a simple way to implement a hex map. I want to have the board made up of hexes. In fact, I am going to attempt to map them to an actual map jpeg I get from the boardgame author.

Would you know where I could get suggestions for this sort of thing? Or source code?

I assume I use a custom view in the map window, but I'm a bit unsure of how to implement the hex class. I assume the custom view will have a 2-d array of hexes, and I'll fiddle with the display so odd numbered rows will be offset up by 1/2 the hex's pixel height, or some such.

Any suggestions would be appreciated. Thanks!

Andrew Kinnie
:D

kainsin
2002.06.06, 10:10 AM
I'm porting a boardgame to computer


Hehe, that sounds pretty funny.

Anyways, it might be easiest to have a 2-dimensional array that represents the tiles as columns ( instead of the traditional representation of rows ). That way you can easily do what you said, move the placement of the hexes of every other column down 1/2 of the height.

I would make images that represent your tiles, and build the display image programatically. Look into the NSImage documentation to use lockFocus/unlockFocus to draw into an NSImage. Then just display the final image. This is probably slow but I doubt you'll need much performance if you're modeling the game after a board game.

akinnie
2002.06.06, 01:33 PM
Thanks for the help!

Andrew

WFleming
2002.06.10, 12:53 AM
Here's a link with a little bit of info, on Isometric and Hexagonal tiles (though it looks like there isn't much there except for some really basic info, so far)

http://www.algonet.se/~afb/gamedev/isohex.html

XxtraLarGe
2002.06.12, 09:34 AM
I'm working on a Hex-based game too, here is a site I found that has some info:

http://www.whisqu.se/per/docs/general39.htm

akinnie
2002.06.12, 09:40 AM
Thanks!

I'm going to work on it a bit today.

Andrew