How to measure the time on a level.

dashnevadadashnevada Member Posts: 58
edited November -1 in Working with GS (Mac)
Hello

I need a little help, I want to record the time it took for the user to finish the level then display it on a screen at the end.

I tried using game.time but that measures the time the entire game has been open. When I chance the scene it doesn't reset.

Any idea how you do this?

thank you very much

Comments

  • heathccheathcc Member Posts: 113
    Could you set an attribute to the game.time when the level loads and then later compare to see how much time has elapsed?
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    have a boolean attribute called recordtime and set it to true and have a real attribute called leveltime and set it to 0

    Have a rule when attribute record time is true every, .1 seconds change attribute leveltime to leveltime+1

    When you finish the level change record time to false and wherever you want to display the time just have a display text behavior and display attribute level time.

    Then when you change to the next level change attribute leveltime to 0 and change recordtime to true.

    If you want to save the times your gonna have to have anther attribute for each level and change it to leveltime before you change to the next scene, and if you want to display it in digital clock format youll have to watch tshirts display time video in the cookbook and in the display text where you dispay the time, use the expresssion he uses
  • MotherHooseMotherHoose Member Posts: 2,456
    or...
    1 gameAttribute real type named startTime
    1 gameAttribute real type named endTime
    additional real game.Attributes for level1Time; level2Time; etc. (for each level)

    in your code (when you initiate changeScene) also changeAttribute game.startTime To: game.Time

    Rule when the goal of the level is met...
    --changeAttribute game.endTime To: game.Time
    --changeAttribute level1Time To: game.endTime-game.startTime

    (you can save that attribute and also show on your tracking/scoring scene Display Text it)

    of course that gives you seconds...not minutes... you divide seconds by seconds per minutes (ex:120/60) to get minutes ...as John says watch Tshirtbooth's video for the function "floor" (rounding down values...) and division parameters...

    MH
  • dashnevadadashnevada Member Posts: 58
    Thank you very much for all your solutions. I solved the problem.

    Thx again
Sign In or Register to comment.