My 2D isometric game uses a hexagonal grid map. In reference to the image below, how do I rotate the light blue hexagon structures by 60 degrees around the pink hexagons?
EDIT:
Main hex is (0,0). Other hexes are children, count of them is fixed. I'm going to define only one position (in this case its right) and calculate other directions if needed (left-bottom, right-botom, right-top, left-top and left). Other hexes are defined like: Package.Add(-1,0), Package.Add(-2,0) and so on.
switch(Direction)
{
case DirRightDown:
if(Number.Y % 2 && Point.X % 2)
Number.X += 1;
Number.Y += Point.X + Point.Y / 2;
Number.X += Point.X / 2 - Point.Y / 1.5;
break;
}
In this code Number
is the main hex and Point
is the hex that I want to rotate, but it doesn't work:
No comments:
Post a Comment