Thanks for your reply! I found & read the tutorial and managed to draw my tile using a vertex array. But I still need to make a lot of draw calls to draw the entire tilemap.
for (int x = 0; x < 50; x++) {
for (int y = 0; y < 50; y++) {
//Check if tile should be drawn
if (mapdata[x][y] == 1) {
sf::Texture tile;
if (!tile.loadFromFile("floor_tile_1.png"))
{
std::cout << "Error could not load floor tile!";
}
//sf::Sprite tilesprite;
//tilesprite.setTexture(tile);
int px = (x - y) * 20;
int py = (x + y) * 20 / 2;
//tilesprite.setPosition(px + 800, py);
//window.draw(tilesprite);
//sf::VertexArray vertices;
//window.draw(vertices, &tile);
sf::VertexArray quad(sf::Quads, 4);
//this serves as some kind of wrapper for the texture?
//tiles; width:42px height: 21px;
//TODO draw with px & py coordinate input
quad[0].position = sf::Vector2f(10.f, 10.f); //top left
quad[1].position = sf::Vector2f(52.f, 10.f); //top right
quad[2].position = sf::Vector2f(52.f, 31.f); //bottom right
quad[3].position = sf::Vector2f(10.f, 31.f); //bottom left
//texture itself is 42x21px
quad[0].texCoords = sf::Vector2f(0.f, 0.f);
quad[1].texCoords = sf::Vector2f(42.f, 0.f);
quad[2].texCoords = sf::Vector2f(42.f, 21.f);
quad[3].texCoords = sf::Vector2f(0.f, 21.f);
window.draw(quad, &tile);
}
}
}
window.display();