centres of the odd numbered rows are offset in the x axis by the radius and in the y axis by .866 of the radius (or do i mean 2 * .866? i can't remember) (.866 is sin(60))
actually, that's wrong. i always do mine the other way around, points upwards and not to the side
anyway, the following will do it, but you'll need to change how you calculate hexcountx and hexcounty
- ...
- for (int i = 0; i < hexcountx; i++){
- for (int j = 0; j < hexcounty; j++){
- if ((j % 2) == 0) {
- hexagon[i][j] = new Hexagon((3 * rad * i), (.866 * rad * j), rad);
- } else {
- hexagon[i][j] = new Hexagon(3 * rad * (i + .5), .866 * rad * j, rad);
- }
- }
- }
- ...