[SOLVED] Need help with scripting differences in scores then displaying them...

Started by Snake, Wed 28/05/2008 23:43:56

Previous topic - Next topic

Snake

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...:
Code: ags

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
Grim: "You're making me want to quit smoking... stop it!;)"
miguel: "I second Grim, stop this nonsense! I love my cigarettes!"

skuttleman

use a separate variable for earned points.
Code: ags

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

Snake

Thank you, that seems to be working for the time being :)

It always seems to be something simple...


--Snake
Grim: "You're making me want to quit smoking... stop it!;)"
miguel: "I second Grim, stop this nonsense! I love my cigarettes!"

SMF spam blocked by CleanTalk