• Advertisement
Sign in to follow this  

Loading globals from a txt file ()

This topic is 4805 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello all! I am making a game for my school project although my questions are about C++ in general. In the beginning of my programm I declare my globals, some of them are arrays of class objects I made for the game (like coins). The amount of objects in the levels of the game differ and I want to repeatedly load this main-game file (.cpp) with different txt files per level. How to declare my globals from a txt file? I want (if possible) to load this main-game file after a choice is made from the menu (like 1 or 2 players, credits etc.). And if you enter lvl2 a new txt file must be loaded into the main-game file's globals. Its rather difficult, cause its a mix of C++ questions && game-programmingstructuredesignquestions *bluh*

Share this post


Link to post
Share on other sites
Advertisement
from what i've read, it sounds like you would have to just have a long coded functions that reads the file and inputs each value into every value individually.

fake code:


ifstream fin;

fin >> coin.value;
fin >> coin.numberofCoins;
fin >> numberofLives;
fin >> numberofEnemies;
fin >> nameofLastBoss;


hopes that helps a little...






Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement