I'm trying to create a basic grid of hex tiles. I found some code:


That does just that, but I think it's setup for hexes that have same length sides. However, my hex has different length sides. Its width is 140 and its height is 80. How would I change that code to accomodate this?


1 Answer 1


Try this: if w,h are the width and height of your tile image, replace the first two lines of that code sample with just

tile._x = x * 0.75 * w;

The factor of 0.75 comes from the geometry of hexagons, where the spacing between adjacent columns is 3/4 of the diameter of a single hexagon. (It's the same origin as the 1.5 in the original code, where s was the side length of the hexagon, which is half its diameter.)


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .