Howzit guys !
I seriously need some help with my High Score scene. I tried using the following example :
https://www.youtube.com/watch?v=7YD1x1aAmJo , but this tutorial focuses on how to save and load High Scores on the same scene. I would like to save my High Scores to a different scene called High Score. I hope this makes sense…
I’ve already done the following :
- Loaded a structure file called “highscores” when player dies.
- Write variable(counter) to “1” of file “highscores”
*Closed structure file.
In my High Score scene I want to show the Top 3 High scores and it needs to be updated every time the player dies with the new High Scores.
I’ll really appreciate if someone can make me an example.
Is it helps in any way?
This example literally save the score and the position of the characters so you can load it on whatever scene you want even after you quit the game.
Otherwise if you just want to “remember” the score while the game is played, you can use global variable to keep it simple.
If you want to keep 3 scores only it’s a bit more difficult, can’t make an example, but this is what I would do:
In the playable scene, when the player dies, you have to check if the new score is greater than some of the 3 highscores, and replace/order them:
The new score wins positions checking from the lowest score to the highest one, swapping lower scores one position down.
Then in the highscore scene just load the 3 scores and show them
Thanks for the replies ddabrahim & Lizard. I think it’s best if I just upload the code. I know it’s just a small error I made somewhere …but I can’t figure out what it is.
It’s pretty weird or I’m missing something, for example when the player dies you save the score in the position 1 of highscores without checking anything, overwriting your best score. Then in the highscores scene you load the score from this first position and test it against the variable 1, read from the first position too, so they have the same value
But I think it will work if you save and read the new player score in/from another group
To be honest I confuse myself sometimes… . I went through the code after taking a break and I’ve almost got it figured out. I will be posting the full code when I’m done. Thanks for your input I really appreciate it.
I solved the problem …and here is the code . Hope it will be of some help to somebody else.
Good to know, not sure how though, as you overwrites the first highscore each time, but if it works it works
After some thorough testing I see what you are talking about… …back to square 1.
I’m retracting my statement…Not Solved !
As I said, from what I can see, instead saving the new score in the group “1” (Player Dies event, second action) save it in another group, for example “score”. And instead reading the score from “1” (HighScore scene, first sub-event, second action), read it from the new group.
You can try that
EDIT: Also, in the Highscore scene, the event that reads the scores into the variables 1, 2 and 3 has the condition “At the beginning of the scene”, but is a sub-event of another with the condition “timer greater than 3 seconds”, so it should never run… but I think (I’ve read) there is a bug with the timers at the beginning of the scenes that lets you do it.
Thanks for the help.I will try your suggestion a bit later and give some feedback tomorrow. I need a break from the PC …my wife is already threatening me with divorce.
Maybe have a beer or two !