[solved] Score counter

i am using this amazing software for about a week now, and i am working on a simple platform game.
Untill now, i have used the forum and the wiki to achieve various thing so i tried to not bother any of you with simple questions. But this time i think i need a hand:
What i wish to obtain is that the score (stored in the global variable “score”), when it is put into the text area, it is counted one by one (1-2-3…1000, 1001, 1002 etc), and not all at once, as it is by now.
Is it possible to achieve that? Maybe with a sound for each point counted?

like this example (without the image stuff, simple text is more than enough).

Yes, it’s possible, but with some work :slight_smile:

I think three variables are needed to have a good effect: The score, the counter (between 0 and score), and a timer to increase the counter.
First, create the TextScore object to display the score, and reset the counter:

Condition: Conditions to get the score Actions: Create TextScore at (the position of the score) Do = 0 to variable "counter"
Always increase the timer (a GD timer could be used instead a variable):

Conditions: No conditions Actions: Do + TimeDelta() to variable "timer"
Now update the counter every X seconds, it should not be bigger than “score”, and reset the “timer”:

[code]Conditions: Vriable “timer” is > X
Actions: Do + “Amount to add” to variable “counter”
Do = 0 to variable “timer”

      Conditions: Variable "counter" > Variable(score)
      Actions: Do = Variable(score) to variable "counter"[/code]

or just

Conditions: Vriable "timer" is > X Actions: Do = min(Variable(score), Variable(counter) + "Amount to add") to variable "counter" Do = 0 to variable "timer"
Update the TextScore:

Conditions: No conditions Actions: Do = VariableString(counter) to the text of TextScore

“Amount to add” could be a constant, but you can set it as a variable, this way you can increase the score faster at the beginning, if the score is too big :wink:
Note that a lot of code could be set as sub-events, to get it all “packed” and nice :smiley:

EDIT: Put “min” instead “max”

Yes it is posible. Here you have an example
ScoreCounter.gdg (6.29 KB)

Hi! thanks for the quick response, to both of you guys. I found the solution starting from the one posted by pleox that i found more simple and yet very effective with the right adjustement.
Pleox you only made a timer, so i modified a bit. Now the counter use 2 scene variable (Thats because i just need it for the end of level scene, where i load the previously saved score from the player and confront it with the best 3 high scores), one is the effective score achieved by the user (for now is only a simple variable set to 1000, for example purposes), and the other is the counter, if the counter is lesser than the score, the count continue, when it reach the value of the “score” variable, it stop. With this method i can trigger other event at the end of the count, like check if it is the topscore and show a medal or something. It’s really great!
Thank you again guys, ill’attach the file on the post so you can check by yourself if it is working.
ScoreCounter.gdg (6.96 KB)