Unlocking multiple endings

Started by Glenjamin, Thu 30/11/2017 18:58:59

Previous topic - Next topic

Glenjamin

I have a game with multiple endings.

I'm trying to make it so every time you get an ending, it unlocks a menu button so you can see the ending again via the main menu.

The endings are controlled by variables, Here's an example:

Code: ags

if (flies == true){
  gtitle.Text = "You got the flies ending!";

  //unlocking ending
  flyending = true;

}else if (flies == false){
   gtitle.Text = "You didn't get the flies ending!";
  //unlocking ending
  noflyending = true;
}


My issue is I need a method of completely resetting the game so the player can try for another ending WITHOUT resetting the progress on the main menu.




Crimson Wizard

#1
Just save the unlocked endings to a file in user's save folder, then load it in the main menu to see which endings were already unlocked.
This will also keep unlocked endings after player quits the game.

Example, writing file when new ending was unlocked (remember you need to write all ending variables at once):
Code: ags

File *f = File.Open("$SAVEGAMEDIR$/endings.dat", eFileWrite);
f.WriteInt(UnlockedEnding1);
f.WriteInt(UnlockedEnding2);
f.WriteInt(UnlockedEnding3);
f.Close();


Reading file when menu is about to be displayed:
Code: ags

File *f = File.Open("$SAVEGAMEDIR$/endings.dat", eFileRead);
UnlockedEnding1 = f.ReadInt();
UnlockedEnding2 = f.ReadInt();
UnlockedEnding3 = f.ReadInt();
f.Close();


More info on file reading/writing may be found in the manual (if needed).

SMF spam blocked by CleanTalk