# How can I make this tile map correctly?

I'm having the following problem creating this hexa tiled map.

this is what I wanted :

[EDIT] Ok I've Managed to do this:

const float scaleX = ((float)tileWidth) / 10000,
scaleY = ((float)tileHeight ) / 10000;
const float hexagon_r = scaleY / 2;
const float hexagon_dx = hexagon_r * cosf(30*3.14f / 180.0);
const float hexagon_dy = hexagon_r * sinf(30*3.14f / 180.0);
const float hexagon_gx = 2.0*hexagon_dx;
const float hexagon_gy = 2.0*hexagon_dx*sinf(60*3.14f / 180.0);
Vector2 auxPos;
auxPos.x = 0;
auxPos.y = 0;
float j = 0;
for (unsigned int y = 0; y < layer->layerHeight; y++, j += hexagon_gx * 2)
{
auxPos.y = y * (hexagon_gy * -2 );
auxPos.x = j;
for (unsigned int x = 0; x < layer->layerWidth; x++)
{

auxPos.x += hexagon_gx * 2;

float angle =90 * 3.14f / 180;

auxPos.y += hexagon_gy * 2;

SetData(stack->vData, stack->vCounter + 0, auxPos.x + ((-scaleX) * cosf(angle) + (-scaleY) * -sinf(angle)));
SetData(stack->vData, stack->vCounter + 1, auxPos.y + ((-scaleX) * sinf(angle) + (-scaleY) * cosf(angle)));
SetData(stack->vData, stack->vCounter + 2, layer->layerDepth);

SetData(stack->vData, stack->vCounter + 3, auxPos.x + ((scaleX) * cosf(angle) + (-scaleY) * -sinf(angle)));
SetData(stack->vData, stack->vCounter + 4, auxPos.y + ((scaleX) * sinf(angle) + (-scaleY) * cosf(angle)));
SetData(stack->vData, stack->vCounter + 5, layer->layerDepth);

SetData(stack->vData, stack->vCounter + 6, auxPos.x + ((scaleX) * cosf(angle) + (scaleY) * -sinf(angle)));
SetData(stack->vData, stack->vCounter + 7, auxPos.y + ((scaleX) * sinf(angle) + (scaleY) * cosf(angle)));
SetData(stack->vData, stack->vCounter + 8, layer->layerDepth);

SetData(stack->vData, stack->vCounter + 9, auxPos.x + ((-scaleX) * cosf(angle) + (scaleY) * -sinf(angle)));
SetData(stack->vData, stack->vCounter + 10, auxPos.y + ((-scaleX) * sinf(angle) + (scaleY) * cosf(angle)));
SetData(stack->vData, stack->vCounter + 11, layer->layerDepth);
}
}


can't seem to make this work...

• I think you would have more luck using (1/3)$pi$ (60 degrees) instead of (1/2)$pi$ (90 degrees). – Jay Dec 23 '18 at 2:39