I made 2 pictures and loaded them:
sf::Texture grass;
if(!grass.loadFromFile("Data/grass.png"))
{
return EXIT_FAILURE;
}
sf::Texture water;
if(!water.loadFromFile("Data/water.png"))
{
return EXIT_FAILURE;
}
Rendered:
sf::RectangleShape t1;
t1.setSize(sf::Vector2f(50, 50));
t1.setTexture(&grass);
sf::RectangleShape t0;
t0.setSize(sf::Vector2f(50, 50));
t0.setTexture(&water);
Then I made this multidimensional array called tile:
sf::RectangleShape tile[4][4] = {
{t1,t1,t1,t1},
{t1,t0,t0,t0},
{t1,t1,t1,t1},
{t0,t0,t0,t0}
};
and added those 2 pictures into it.
Now when I draw this:
window.clear();
windw.draw(tile[0][0]);
window.display();
Program draws the t1 rectangle shape.
So, my question is how I can draw all those 16 items in array so they are placed like in array.
I tried to make a for loop like this:
for(int x=0;x<4;x++)
{
for(int y=0;y<4;y++)
{
window.draw(tile[x][y]);
}
}
Program just draws the tile[3][3] which is t0;
I hope you understand my english and sorry if this is a stupid question.