Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Snake on Wed 28/05/2008 23:43:56

Title: [SOLVED] Need help with scripting differences in scores then displaying them...
Post by: Snake on Wed 28/05/2008 23:43:56
Hey, guys - again,

Now, at the end of a mini game I want the difference between the player score and the CPU score to be added to the number of points on the title screen of the mini game.
When you initially start, you have 0 points (called, Earned Points).

So, let's say you won 10 to 5. The difference is 5, so this will be added to the final score on the title.

If your earned points were at 0, then it would now be 5.

Now, let's say you play again and lose 6-7. The difference is 1. This is now going to have to be taken away from your earned points; 5-1=4.
I'm also guessing that it doesn't matter if you check if playerscore is higher or lower than cpuscore since adding -1 to 5 is going to be 4 anyway. If it's not, I'm even more of an idiot when it comes to math than what I thought.

The player and cpu score variables are:
playerscore
cpuscore


The gui's label that displays your earned points on the title screen is named, epoints.

At the end of the game I need the difference of playerscore and cpuscore and add it to epoints.

I already know how to display the points, so don't worry about explaining that.

Doing it this way...:

epoints.Text = String.Format("%d",playerscore-cpuscore);

...works if I wanted the previous score of each game, but I want it added to it (like earning money and actually being able to keep it), and this is where I'm stuck.

Thanks in advance, help is much appreciated,


--Snake
Title: Re: Need help with scripting differences in scores and then displaying them...
Post by: skuttleman on Wed 28/05/2008 23:49:51
use a separate variable for earned points.

earnedpoints = earnedpoints + (playerscore-cpuscore);
epoints.Text = String.Format("%d",earnedpoints);
Title: Re: Need help with scripting differences in scores and then displaying them...
Post by: Snake on Thu 29/05/2008 00:18:29
Thank you, that seems to be working for the time being :)

It always seems to be something simple...


--Snake