Ok so I might just be missing something but I am trying to make a hex board map, like in civilizations. The idea is to have each hex as an object that has various properties(ie, color, type, etc). Then have a board of all these various hexes. There would be 3 board types, rectangle, circle, triangle.
The issue I am having is how to represent each hex in a data type. I figured a 2 dimensional array would be the way to go, which would be fine if I just needed to know the hex locations themselves. But I will need to know the vertexes and edges of each hex so that I can do things like on the edge between these to hexes add this. That is what is confusing me. How to represent each hex with all sides and points in an way in which I can ask for neighbors connected to that point or edge etc.
Any ideas, I have read many articles about this, but for some reason I still don’t understand, maybe because it is all ideas and I have no clue hoe to implement it.
A 2-dimensional array would reinforce the concept of a rectangular grid.
Why not instead define a
Cellclass, with references to the neighbouring cells thus:The references would be null for
Cellson the boundaries of your grid.You’d have to construct the grid by iterating through the rows, creating each
Celland tying it to its neighbours as appropriate.