开发者

Parsing in a textfile in C++

Merged with Ifstream getting information from a te开发者_开发百科xtfile.

At the moment I'm making a simply 3D race game and I would like the the ground textures to be modable via a text file. I know there are other, "better" ways of doing this, but I want to use the ifstream so I gain a better understanding of how it works.

In my code I have already set up a grid on the ground for where the track is going placed, and I have one texture that covers the entirity of it.

Here is a code block of how I'm trying to use the ifstream to load in different textures

string line;
ifstream myfile ("track1.txt");
if (myfile.is_open())
{
    while ( myfile.good() )
    {
        getline (myfile,line);
        if( line == 0)
        {
             const wstring textureFileName=TEXT("crate.jpg");
        }
    }
    myfile.close();
}

My text file is simply one line of of ten 0 in a row. Each 0 is separated by a comma like so

0,0,0,0,0,0,0

Have I set up the ifstream correctly to do what I require it to do?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜