Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: on Thu 27/01/2005 16:41:10

Title: Winning the Game? [SOLVED]
Post by: on Thu 27/01/2005 16:41:10
It sounds like a very simple problem. When the player has the full score, how do I tell the game to play the ending scenes ? And where do I put the code in the global script ?
Title: Re: Winning the Game ?
Post by: Ashen on Thu 27/01/2005 17:07:18
I think you want to use the GOT_SCORE parameter of the on_event function. By default, I don't think on_event exists in the script, so you'll have to create it if you haven't already. Something like:


function on_event (int event, int data) {
Ã,  if (event == GOT_SCORE) { // Called whenever score changes
Ã,  Ã,  if (game.score == game.total_score ) { // fairly self-explainatory
      Display ("Congratulations, you've won.");
Ã,  Ã,  Ã,  NewRoom (300);
      // Or whatever you want to happen
Ã,  Ã,  }
Ã,  }
}


It can go anywhere in the global script, provided it's not inside another function.
Title: Re: Winning the Game ?
Post by: on Thu 27/01/2005 19:42:05
Thanks ! Problem solved !
Title: Re: Winning the Game ?
Post by: TerranRich on Fri 28/01/2005 01:22:06
Updated BFAQ: http://bfaq.terran-x.com/#graphics13

Credit given to Ashen for the quoted code as well. :)