vertices.setPrimitiveType(sf::TrianglesFan);
vertices.resize(map_width * map_height *
;
int relative_offset = 2;
int hex_size = 64;
int offset = relative_offset * hex_size;
float height = hex_size * 2;
float width = std::sqrt(3) * hex_size;
for (unsigned int i = 0; i < map_width; ++i)
{
for (unsigned int j = 0; j < map_height; ++j)
{
// get the current tile number
int tileNumber = tiles[i + j * map_width];
// find its position in the tileset texture
//int tx = tileNumber % (m_tileset.getSize().x / (int)width);
//int ty = tileNumber / (m_tileset.getSize().x / width);
// get a pointer to the current tile's hex
sf::Vertex* hex = &vertices[(i + j * map_width) * 8];
// define its centre
hex[0].position = sf::Vector2f(offset + i * width, offset + j * height);
//define its corners
for (int k = 1; k <= 6; k++)
{
float angle = 2 * PI / 6 * (k + 0.5);
hex[k].position = sf::Vector2f(
offset + i * width + hex_size * cos(angle),
offset + j * height + hex_size * sin(angle));
}
hex[7].position = sf::Vector2f(hex[1].position.x, hex[1].position.y);
printf("%f\n", hex[0].position.x);
hex[0].color = sf::Color::Red;
for (int k = 1; k <= 4; k++)
{
float angle = 2 * PI / 6 * (k + 0.5);
hex[k].color = sf::Color::Cyan;
}
}
}