Can anybody answer these questions for my next game?
1.How do you save a game (I know how to save a score, but not a game)
2.How do you make a typing box
PLEASE HELP!
Rux wrote:Game A Gogo wrote:ah, saving game is pretty easy!
I shall make a demo?
Please post a link or post the demo in this topic.
FILE*file;
file = fopen("Game", "r+b");
fread(&variable1, sizeof(variable1), 1, file);
fread(&variable2, sizeof(variable2), 1, file);
//ect.
fclose(file);
so and so Actor.x = variable_whatever; //ect.
FILE*file;
so and so variable_whatever = Actor.x; //ect.
file = fopen("Game", "w+b");
fwrite(&variable1, sizeof(variable1), 1, file);
fwrite(&variable2, sizeof(variable2), 1, file);
//ect.
fclose(file);
Kodo wrote:It'll be easier if you only allow the player to save between levels or at checkpoints where there is less to worry about. You could create a save game in this manner by just saving a few common grouped variables like the ones listed below with saveVars(“filename”, “group”)
current_level
player_score
player_health
lives_remaining
When you create the variables you want to save you can put them in a Save Group, this group will be what the saveVars/loadVars functions load and save. If you need to you can edit variables to place them in a save group after they have been created.
When the player chooses to reload their saved game you load the data again using loadVars(“filename”, “group”) , look at the level and place the character and/or view in the correct position, set all the other saved variables and off you go!
Taking this approach you really don’t need to worry about where all the monsters were, which pickups the player has already cleared from a level, were there bullets flying about the place? which frames of animation were all the sprites on? what damage had been done to the environment and on and on etc etc. It's much simpler.
If you are worrying about keeping track of remapped controls, music/fx volumes and other optional stuff I prefer to keep those saved in a separate player profile group that I can load and save in the front end menus and also load when starting up the game separately from the save game info.
lolSgt. Sparky wrote:But But....
Thats to easy!
FILE*file;
file = fopen("Game", "r+b");
fread(&PlayB_Var, sizeof(PlayB_Var), 1, file);
fread(&Menu_var, sizeof(Menu_var), 1, file);
fread(&QuitB_Var, sizeof(QuitB_Var), 1, file);
fread(&Register_Var, sizeof(Register_Var), 1, file);
fread(&Seirial_Var, sizeof(Seirial_Var), 1, file);
fread(&Sessions_Var, sizeof(Sessions_Var), 1, file);
fread(®isterthegame_Var, sizeof(registerthegame_Var), 1, file);
fread(&sep_Var, sizeof(sep_Var), 1, file);
fread(&session_Var, sizeof(session_Var), 1, file);
fclose(file);
PlayB.x = PlayB_Var;
Menu.x = Menu_var;
QuitB.x = QuitB_Var;
Register.x = Register_Var;
registerthegame.x = registerthegame_Var;
Seirial.x = Seirial_Var;
sep.x = sep_Var;
session.x = session_Var;
Sessions.x = Sessions_Var;
Users browsing this forum: No registered users and 1 guest