Hello,
I'm learning SFML and I don't know how to handle this problem.
I have VertexArray:
if (!m_Tileset.loadFromFile("./resources/tiles/tile.png")) { //Tileset got only one tile
throw("Cant load tileset");
return false;
}
int width, height;
width = height = 150;
m_Vertices.setPrimitiveType(sf::Quads);
m_Vertices.resize(width * height * 4);
sf::Vector2f tileSize(64, 64);
for (unsigned int i = 0; i < width; ++i)
for (unsigned int j = 0; j < height; ++j)
{
sf::Vertex* quad = &m_Vertices[(i + j * width) * 4];
quad[0].position = sf::Vector2f(i * tileSize.x, j * tileSize.y);
quad[1].position = sf::Vector2f((i + 1) * tileSize.x, j * tileSize.y);
quad[2].position = sf::Vector2f((i + 1) * tileSize.x, (j + 1) * tileSize.y);
quad[3].position = sf::Vector2f(i * tileSize.x, (j + 1) * tileSize.y);
quad[0].texCoords = sf::Vector2f(tileSize.x, 0);
quad[1].texCoords = sf::Vector2f(tileSize.x,0);
quad[2].texCoords = sf::Vector2f(tileSize.x, tileSize.y);
quad[3].texCoords = sf::Vector2f(0, tileSize.y);
}I would like to add game object (like trees/castles etc.) to my TiledMap having record, where they was added.
Like on these pictures..
Before adding I have TiledMap like this:
And after adding trees, I need to know that tree's texture is intersecting with rectangles at coords [3,2],[4,2],[5,2], [3,1], [3,2] etc..
I have no idea how to do that. I would be grateful for any advice.
Thank you!