I've followed some of his tutorials so I can tell you one thing you are doing wrong your'e using the easy way. Always go for the Intermediate or the Hard way because they are harder but more effective. Anyway here as code that should work:
#include <SFML/Graphics.hpp>
#include <iostream>
#include <cctype>
#include <fstream>
#include <vector>
#include <string>
int main()
{
std::ifstream openfile("Map.txt");
sf::Texture tileTexture;
sf::Sprite tiles;
std::vector<std::vector<sf::Vector2i> > map;
std::vector<sf::Vector2i> tempMap;
while(openfile.is_open()){
std::string tileLocation;
openfile >> tileLocation;
if(!tileTexture.loadFromFile(tileLocation)){
return EXIT_FAILURE;
}
tiles.setTexture(tileTexture);
while(!openfile.eof()){
std::string tile;
openfile >> tile;
char x = tile[0], y = tile [2];
if(!isdigit(x) || !isdigit(y)){
tempMap.push_back(sf::Vector2i(-1,-1));
}
else{
tempMap.push_back(sf::Vector2i(x - '0', y - '0'));
}
if (openfile.peek() == '/n'){
map.push_back(tempMap);
temMap.clear();
}
}
map.push_back(tempMap);
}
sf::RenderWindow Window (sf::VideoMode(800,600,32),"SFML");
while(!Window.isOpen()){
sf::Event event;
if(event.type == sf::Event::Closed){
Window.close();
}
Window.clear();
for(int i = 0; i < map.size(); i++){
for(int j = 0; j < map[i].size(); j++){
if(map[i][j].x != -1 && map[i][j].y != -1){
tiles.setPosition(j * 32, i * 32);
tiles.setTextureRect(sf::IntRect(map[i][j].x * 32, map[i][j].y * 32, 32, 32));
Window.draw(tiles);
}
}
}
Window.display();
}
}
And this how your Map.txt file should be:
Map.png
x,x x,x x,x x,x x,x x,x x,x x,x x,x x,x
x,x x,x x,x x,x x,x x,x x,x x,x x,x x,x
x,x x,x x,x x,x x,x x,x x,x x,x x,x x,x
x,x x,x x,x x,x x,x x,x x,x x,x x,x x,x
x,x x,x x,x x,x x,x x,x x,x x,x x,x x,x
x,x x,x x,x x,x x,x x,x x,x x,x x,x x,x
x,x x,x x,x x,x 0,1 1,0 1,1 x,x x,x x,x
x,x x,x x,x x,x x,x x,x x,x x,x x,x x,x
0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0
This one is the one
I use but it's not the most effective. If you want the most effective of them all watch codingmadeeasy tutorial on Loading Tile Maps[Hard];