title: SFML platformer using c++
body: <p>Hey im currently making an sfml platformer and going to use map tiles however after implementing my map class it is coming up with an unhandled exception.
  i call the initialise function first and then drawmap at the end. here is the code..</p>
  
  <pre><code>    void Map::Initialise(const char *filename)
  {
       std::ifstream openfile(filename);
      if(openfile.is_open())
      {
          std::string tempLine;
          std::getline(openfile, tempLine);
  
          tempLine.erase(std::remove (tempLine.begin(), tempLine.end(), ' '), tempLine.end());
          MapX = tempLine.length();
  
          openfile.seekg(0, std::ios::beg);
  
          while(!openfile.eof())
          {
  
              openfile &gt;&gt; MapFile[loadCountX][loadCountY];
              loadCountX++;
              if(loadCountX &gt;= MapX)
              {
                  loadCountX = 0;
                  loadCountY++;
              }
          }
          MapY = loadCountY;
      }
  
  }
  
  void Map::DrawMap(sf::RenderWindow &amp;Window)
  {
      sf::Shape rect = sf::Shape::Rectangle(0, 0, BLOCKSIZE, BLOCKSIZE, sf::Color(255, 255, 255, 255));
      sf::Color rectCol;
      for(int i = 0; i &lt; MapX; i++)
      {
          for(int j = 0; j &lt; MapY; j++)
          {
              if(MapFile[i][j] == 0)
                  rectCol = sf::Color(44, 117, 255);
              else if (MapFile[i][j] == 1)
                  rectCol = sf::Color(255, 100, 17);
  
              rect.SetPosition(i * BLOCKSIZE, j * BLOCKSIZE);
              rect.SetColor(rectCol);
              Window.Draw(rect);
          }
      }
  </code></pre>