Loading a level, reload my main.cpp file?
Hello, I am making a game for my school project and Im having some troubles with loading a level.
Right now all variables for the first level are declared and initialized inside my code, but I want to get it extern - in a text file to be exact -.
I already asked in the 'General Programming' forum how I should do this, but there is 1 more thing that is 'Game Programming' like:
Many examples I have seen have a menu inside their main-game file (main.cpp for example), I think this is fairly logic but I want to reload my main.cpp file everytime I enter a new level so it would not be smart to throw in my outer layer code (the main menu) inside this reloadable .cpp file.
Please try to picture my situation, should I continue in this direction? Or should I not graduate cause of this? :P
This is why you need to use a gamestate variable(Or a class) and move your level code into it's own class aswell.
Make a class Level, and give the level to your PlayGame(&Level); function. This way, if your gamestate is set to "load new level", you load a new level, change state to playgame, and hand in the level object.
Toolmaker
Make a class Level, and give the level to your PlayGame(&Level); function. This way, if your gamestate is set to "load new level", you load a new level, change state to playgame, and hand in the level object.
Toolmaker
yup. NEVER put a level code into your main loop. otherwise you will be loading and reloading the main.cpp all the time. just make the software check if the level is done, and then call the next level
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement