#include <SFML/Graphics.hpp>
int main() {
sf::RenderWindow window(sf::VideoMode(640, 480), "Demo");
sf::Texture tile;
tile.loadFromFile("tile.png");
sf::VertexArray array(sf::Quads, 16);
// topleft tile
array[0].position = sf::Vector2f(0.f, 0.f);
array[0].texCoords = sf::Vector2f(0.f, 0.f);
array[0].color = sf::Color::Black;
array[1].position = sf::Vector2f(64.f, 0.f);
array[1].texCoords = sf::Vector2f(64.f, 0.f);
array[1].color = sf::Color::Black;
array[2].position = sf::Vector2f(64.f, 64.f);
array[2].texCoords = sf::Vector2f(64.f, 64.f);
array[2].color = sf::Color::White;
array[3].position = sf::Vector2f(0.f, 64.f);
array[3].texCoords = sf::Vector2f(0.f, 64.f);
array[3].color = sf::Color::Black;
// topright tile
array[4].position = sf::Vector2f(64.f, 0.f);
array[4].texCoords = sf::Vector2f(0.f, 0.f);
array[4].color = sf::Color::Black;
array[5].position = sf::Vector2f(128.f, 0.f);
array[5].texCoords = sf::Vector2f(64.f, 0.f);
array[5].color = sf::Color::Black;
array[6].position = sf::Vector2f(128.f, 64.f);
array[6].texCoords = sf::Vector2f(64.f, 64.f);
array[6].color = sf::Color::Black;
array[7].position = sf::Vector2f(64.f, 64.f);
array[7].texCoords = sf::Vector2f(0.f, 64.f);
array[7].color = sf::Color::White;
// bottomright tile
array[8].position = sf::Vector2f(64.f, 64.f);
array[8].texCoords = sf::Vector2f(0.f, 0.f);
array[8].color = sf::Color::White;
array[9].position = sf::Vector2f(128.f, 64.f);
array[9].texCoords = sf::Vector2f(64.f, 0.f);
array[9].color = sf::Color::Black;
array[10].position = sf::Vector2f(128.f, 128.f);
array[10].texCoords = sf::Vector2f(64.f, 64.f);
array[10].color = sf::Color::Black;
array[11].position = sf::Vector2f(64.f, 128.f);
array[11].texCoords = sf::Vector2f(0.f, 64.f);
array[11].color = sf::Color::Black;
// bottomleft tile
array[12].position = sf::Vector2f(0.f, 64.f);
array[12].texCoords = sf::Vector2f(0.f, 0.f);
array[12].color = sf::Color::Black;
array[13].position = sf::Vector2f(64.f, 64.f);
array[13].texCoords = sf::Vector2f(64.f, 0.f);
array[13].color = sf::Color::White;
array[14].position = sf::Vector2f(64.f, 128.f);
array[14].texCoords = sf::Vector2f(64.f, 64.f);
array[14].color = sf::Color::Black;
array[15].position = sf::Vector2f(0.f, 128.f);
array[15].texCoords = sf::Vector2f(0.f, 64.f);
array[15].color = sf::Color::Black;
while (window.isOpen()) {
sf::Event event;
while (window.pollEvent(event)) {
if (event.type == sf::Event::Closed) {
window.close();
}
}
window.clear(sf::Color::Black);
window.draw(array, &tile);
window.display();
}
return 0;
};