I made this tiled map with vectors.
First I made vectors for 4x4 map:
std::vector< std::vector<int> > map(4, std::vector<int>(4));
// Define the map
map[0][0] = 0;
map[0][1] = 1;
map[0][2] = 0;
map[0][3] = 0;
map[1][0] = 0;
map[1][1] = 0;
map[1][2] = 0;
map[1][3] = 0;
map[2][0] = 0;
map[2][1] = 0;
map[2][2] = 0;
map[2][3] = 0;
map[3][0] = 0;
map[3][1] = 0;
map[3][2] = 0;
map[3][3] = 1;
Then I made sprites for grass and water:
std::vector<sf::Sprite> tiles(2);
tiles[0] = sf::Sprite(grass);
tiles[1] = sf::Sprite(water);
And then draw it:
for (int x = 0; x < map.size(); x++)
{
for (int y = 0; y < map[x].size(); y++)
{
int tileId = map[x][y];
tiles[tileId].setPosition(x * 100, y * 100);
window.draw(tiles[tileId]);
}
}
I also added a rectangle and movement.
Now I don't know how to acces water tiles and add collision to them.
Sorry for my english.
Reply if you need full code.