0

こんにちは、マッピング用のクラスがあり、画面に描画していますが、ウィンドウの左側を垂直に描画するだけです。私はどこで間違ったのかを理解することができます。どんな助けでも大歓迎です。draw関数のforループと関係があることは間違いありません。

void Map::Initialise(const char *filename)
{
     std::ifstream openfile(filename);
     std::string line;
     std::vector <int>  tempvector;
    while(!openfile.eof())
    {
        std::getline(openfile, line);

        for(int i =0; i < line.length(); i++)
        {
            if(line[i] != ' ') // if the value is not a space
            {
                char value[1] = {line[i]}; // store the character into the line variable
                tempvector.push_back(atoi(value)); // then push back the value stored in value into the temp vector
            }
            mapVector.push_back(tempvector); // push back the value of the temp vector into the map vector
            tempvector.clear(); // clear the temp vector readt for the next value
        }
    }
}


void Map::DrawMap(sf::RenderWindow &Window)
{
    sf::Shape rect = sf::Shape::Rectangle(0, 0, BLOCKSIZE, BLOCKSIZE, sf::Color(255, 255, 255, 255));
    sf::Color rectCol;
    sf::Sprite sprite;
    for(int i = 0; i < mapVector.size(); i++)
    {
        for(int j = 0; j < mapVector[i].size(); j++)
        {
            if(mapVector[i][j] == 0)

               rectCol = sf::Color(44, 117, 255);

            else if (mapVector[i][j] == 1)

                rectCol = sf::Color(255, 100, 17);

            rect.SetPosition(j * BLOCKSIZE, i * BLOCKSIZE);
            rect.SetColor(rectCol);
            Window.Draw(rect);

        }
    }
}
4

1 に答える 1