Hello, in efforts to clean up my code, I have decided to use files to store data. So far im working on loading the data in the first place. I have a file called Loading.txt and inside I have 3 lines:
times.ttf
music.ogg
Scene1.jpg
Images//NPC.jpg
Now this is my function so far:
sf::Font font;
sf::Music music;
void Load()
{
std::ifstream loadfile("load.txt");
std::getline(loadfile,filepath);
font.loadFromFile(filepath);
std::getline(loadfile,filepath);
music.openFromFile(filepath);
//etc...
loadfile.close();
}
So far I have globally declared textures,font,music. etc, and i hard code in each one for loading.The part where im stuck at is, how should I approach implementing the Font, Music, and Textures. Would it be better to just hard code in a list of textures like I am currently doing, or is there a way to create them on the go? I dont know if im explaining it correctly but essentially is it possible to create a function that can read from the file and create a texture, font, or music object and then load it for use later down the line? At most I will have about 5 images on the screen at a time, so I was also thinking about just hard coding 5 textures and changing around each path and reloading when needed. Which do you guys recommend?