Saving "best time" score
Marc_n_Soph
Member Posts: 111
Hi. This sould be the last thing I need help with and I can complete my game!!
Im trying to show the time the player completed a course in, then check that against the best time the level has been completed in, and update best time if applicable.
I have
Timer (real)
Your Time Lvl 1(real)
Best Time Lvl 1(real)
player completes level, (they have 60 seconds) timer is stopped.
then a screen is shown saying "your time" is displayed.
actor "Your time" displaying text game.timer
rule
if your time < best time
change attrib best time - your time
save attrib - best time.
then they hit next to continue.
On my title screen, I have a button "best times" which takes them to another scene showing "best time level one, level two etc.
On best times scene, actor - display text game.best time lvl1
and on title scene i have invis actor with load attrib best time.
but it dont work.
I can get "your time" to display, but as soon as I add the if your time < best time rule, it all just shows as zeros.
Where did it all go wrong???!?!?!
Any help greatly appreciated, Im running out of walls to de-stress my head on.
Thanks loads
Marc n Soph
Im trying to show the time the player completed a course in, then check that against the best time the level has been completed in, and update best time if applicable.
I have
Timer (real)
Your Time Lvl 1(real)
Best Time Lvl 1(real)
player completes level, (they have 60 seconds) timer is stopped.
then a screen is shown saying "your time" is displayed.
actor "Your time" displaying text game.timer
rule
if your time < best time
change attrib best time - your time
save attrib - best time.
then they hit next to continue.
On my title screen, I have a button "best times" which takes them to another scene showing "best time level one, level two etc.
On best times scene, actor - display text game.best time lvl1
and on title scene i have invis actor with load attrib best time.
but it dont work.
I can get "your time" to display, but as soon as I add the if your time < best time rule, it all just shows as zeros.
Where did it all go wrong???!?!?!
Any help greatly appreciated, Im running out of walls to de-stress my head on.
Thanks loads
Marc n Soph
Comments
Yeah, say the best time set for a level completed is 57 seconds, and then the player completes it in say, 45 seconds, Im trying to update the "best time" to 45 seconds, so Im thinkin the < (less than) would work?
Just like to point out that I have looked through forums and tried a tutorial on youtube too, but just cant seem to get this to work!! Dont want anyone thinkin I've just dived in to be rescued (again) without doin some homework first!!
I appreciate there is more than likely a MUCH better way of doin this than the way im tryin, and ANY help would be awesome.
Thanks loads
Marc n Soph
Darren.
Nice one. Didnt think of that. I cant try it right now cos im at work. U think everythin else should work? Does it all seem ok? REALLY wanna get this bit sorted, then I can get my game finished!!!!!
Marc n Soph
ps haha nice one polygame
Just need to find out how to reset the timer when retry is hit cos at the mo it reads the first time recorded every time the level is played!!
The real problem comes when I try to make a "Best time level one" scene. I just cant get my head around the keys and saving and replacing - when level time < best time change atribb etc. TSB ... FMG ... any other three letter legends ... if you read this... please help!!! Im NEARLY THERE with my first game!!! Worked so hard on the graphics and learnin GS so far, its the timer thats kickin my ass!!
Thanks for any help / advice
Marc
You simply make a real attribute for each level, something like this:
level_1_best
level_2_best
level_3_best
etc.
etc.
You should also have a real attribute called something like 'currentLevelTime'.
Whenever you complete a level, have a Rule like this:
Rule
When all conditions are valid:
game.currentLevelTime < game.level_1_best
-----Change Attribute: game.level_1_best To: game.currentLevelTime
-----Save Attribute: game.level_1_best To Key: LEVEL_1_BEST
That is how you save an attribute.
To load it, simply put this behavior in an actor in a Scene BEFORE you need to display it, maybe your logo scene or your main menu?
Load Attribute: game.level_1_best From Key: LEVEL_1_BEST
Hope this helps!
Joe
QS
Dr. Sam Beckett never returned home...
Twitter: https://twitter.com/Quantum_Sheep
Web: https://quantumsheep.itch.io
Nice work on ALL your stuff by the way.
Thanks again Joe and everyone!!
Marc
Jeez, Get it right. lol!!