Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Play_Pretend on Sun 16/12/2007 22:34:13

Title: Two Player Score Displays? [SOLVED]
Post by: Play_Pretend on Sun 16/12/2007 22:34:13
Hey all...I've read the manual and searched the threads and experimented, and I'm still lost.  :(  I'm trying to display two GUIs, to continuously show two player scores on the screen, for a game show.  For example, I've tried using this:

    int scorered = (scorered + 18);
    rscore.Text = String.Format("%d", scorered);

To add 18 points to the Red Team's score.  The GUI text does change to 18.  But then if I repeat the command to add another say, 44 points, it just changes it to 44, instead of adding them together to make 62.  Is the String.Format command just resetting it to the new value every time?

How can I make both scores show continuously in their GUI windows, and then be able to add points to either depending on who answers the question correctly?  Please help, I've been tearing my hair out over this for five hours now. :)
Title: Re: Two Player Score Displays?
Post by: Ashen on Sun 16/12/2007 22:46:40
If that's exactly what you're doing, you're redeclaring the varaible each time - meaning it's set to 0 Plus the new score, not the old score plus the new score. Declare the variable (int scorered;) at the top of the script, and just add to it when points are scored, and it should work fine. That's just basic variable handling, nothing to do with String.Format.

Having both scores displayed should just be a case of having a line to set each, e.g.:

rscore.Text = String.Format("%d", scorered);
bscore.Text = String.Format("%d", bluescore);


You can either call that every time points are added, or stick it in repeatedly_execute to have it automaticaly update.
Title: Re: Two Player Score Displays?
Post by: Play_Pretend on Sun 16/12/2007 23:02:09
Ah!  Sweet!  I get it...okay, I deleted the String.Format lines from the questions, and just plugged in those two like you said in Repeatedly Execute.  I stuck the two redscore and bluescore ints at the very top of the Global Script.  Then I just use the

   scorered = (scorered + 44);

Or whatever line whenever someone gets a correct answer, and it works like a charm!  Thanks a ton Ashen!!! :)

Ahhh...blood pressure...falling...
Title: Re: Two Player Score Displays? [SOLVED]
Post by: monkey0506 on Tue 18/12/2007 05:20:59
Just FYI, you don't have to do "scorered = (scorered + 44);", you can use the syntax "scorered += 44;" instead. It's a bit simpler way of increasing the current value of a variable.