Dobuki Studio Interview Question
Game ProgrammersCountry: United States
I see the 2D array differently.
If you line up the hexes into rows, either by shifting the even columns up half a row or the odd columns down half a row, you get a 2d array.
From any position in the 2d array you can go left, right, up, or down.
For odd columns you can additionally go up left and up right.
For even columns you additionally go down left and down right.
I'm not seeing why in the answer provided by tjcbs you can only go up/down + right on even rows and up/down + left on odd rows.
You can represent a hex map as an ordinary grid (2D array). Movement is a bit different. Horizontal movement is the same as with a grid. But Vertical movement is different: in terms of the 2d array, a unit on even rows can move up, down, up and right, down and right. A unit on odd rows can move up, down, up and left, down and left.
- tjcbs2 May 12, 2015