Author Topic: Unlocking multiple endings  (Read 222 times)

Glenjamin

  • video games are for nerds
Unlocking multiple endings
« on: 30 Nov 2017, 18:58 »
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: Adventure Game Studio
  1. if (flies == true){
  2.   gtitle.Text = "You got the flies ending!";
  3.  
  4.   //unlocking ending
  5.   flyending = true;
  6.  
  7. }else if (flies == false){
  8.    gtitle.Text = "You didn't get the flies ending!";
  9.   //unlocking ending
  10.   noflyending = true;
  11. }
  12.  

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

  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: Unlocking multiple endings
« Reply #1 on: 30 Nov 2017, 19:14 »
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: Adventure Game Studio
  1. File *f = File.Open("$SAVEGAMEDIR$/endings.dat", eFileWrite);
  2. f.WriteInt(UnlockedEnding1);
  3. f.WriteInt(UnlockedEnding2);
  4. f.WriteInt(UnlockedEnding3);
  5. f.Close();
  6.  

Reading file when menu is about to be displayed:
Code: Adventure Game Studio
  1. File *f = File.Open("$SAVEGAMEDIR$/endings.dat", eFileRead);
  2. UnlockedEnding1 = f.ReadInt();
  3. UnlockedEnding2 = f.ReadInt();
  4. UnlockedEnding3 = f.ReadInt();
  5. f.Close();
  6.  

More info on file reading/writing may be found in the manual (if needed).
« Last Edit: 30 Nov 2017, 19:16 by Crimson Wizard »