Saving "best time" score

Marc_n_SophMarc_n_Soph Member Posts: 111
edited November -1 in Working with GS (Mac)
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

Comments

  • reddotincreddotinc Member Posts: 653
    you have set "if your score is LESS THAN (<) Best time, then set your score to best score"?
  • Marc_n_SophMarc_n_Soph Member Posts: 111
    Hi swiftmedia, thanks for postin.

    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
  • UtopianGamesUtopianGames Member Posts: 5,692
    Is it because the real variable best time is set to 0 try setting to 60 that should work because a best time of 0 will never be beaten.

    Darren.
  • AfterBurnettAfterBurnett Member Posts: 3,474
    Superman could beat it. He can fly backwards through time. I saw him do it once, saved Lois Lane.
  • Marc_n_SophMarc_n_Soph Member Posts: 111
    Ahhh ... well spotted 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
  • Marc_n_SophMarc_n_Soph Member Posts: 111
    Hmm ... no joy. I downloaded FMGs time tutorial / demo, now THAT is how to deal with time. However, its all a bit above me. Tried usin game.time to record the level completed time, but could not do it. Just want my timer to start when my actor hits "start timer" actor (it works) and stop when it hits "end level" actor (this works too!!) I save the stopped timer as Your Time Level 1, and then display it on Your Time scene. It works!!
    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
  • firemaplegamesfiremaplegames Member Posts: 3,211
    If you are simply having a best time for each level, that is fairly easy to do.

    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
  • quantumsheepquantumsheep Member Posts: 8,188
    Thanks for posting that Joe - I'm thinking of including a 'best time per level', and that really helps keep things simple!

    QS :D

    Dr. Sam Beckett never returned home...
    Twitter: https://twitter.com/Quantum_Sheep
    Web: https://quantumsheep.itch.io

  • Marc_n_SophMarc_n_Soph Member Posts: 111
    Oh thats just awesome m8 thanks so so much. Im on my way to work right now, so ill hav to do that tonight. REALLY appreciate that Joe, I now you must be busy so thanks for takin time out to help.

    Nice work on ALL your stuff by the way.

    Thanks again Joe and everyone!!

    Marc
  • JamesZeppelinJamesZeppelin Member Posts: 1,927
    POLYGAMe said:
    Superman could beat it. He can fly backwards through time. I saw him do it once, saved Lois Lane.

    He didnt fly backwards through time. He just flew so fast he made time go backwords...

    Jeez, Get it right. lol!!
Sign In or Register to comment.