iDevGames Forums
Cocoa Hex Based Game question - Printable Version

+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Game Programming Fundamentals (/forum-7.html)
+--- Thread: Cocoa Hex Based Game question (/thread-7720.html)



Cocoa Hex Based Game question - akinnie - Jun 6, 2002 05: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
Grin


Cocoa Hex Based Game question - kainsin - Jun 6, 2002 07:10 AM

Quote: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.


Cocoa Hex Based Game question - akinnie - Jun 6, 2002 10:33 AM

Thanks for the help!

Andrew


Cocoa Hex Based Game question - WFleming - Jun 9, 2002 09:53 PM

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


Cocoa Hex Based Game question - XxtraLarGe - Jun 12, 2002 06: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


Cocoa Hex Based Game question - akinnie - Jun 12, 2002 06:40 AM

Thanks!

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

Andrew