Help with calculating time, please :)

Welcome to our brand new Clickteam Community Hub! We hope you will enjoy using the new features, which we will be further expanding in the coming months.

A few features including Passport are unavailable initially whilst we monitor stability of the new platform, we hope to bring these online very soon. Small issues will crop up following the import from our old system, including some message formatting, translation accuracy and other things.

Thank you for your patience whilst we've worked on this and we look forward to more exciting community developments soon!

Clickteam.
  • In the game I am working on, I want to keep track of how long the player has been playing. I want the time taking to be more accurate than whole seconds, so I need to make use of the 1/100 part of the default time keeping system somehow.

    Apparently 1/100 is not 1/100 of a second. When I use a counter that adds one "second" each time it reaches 100, based on the 1/100 system, it takes longer than a second. It seems, however, that I get the correct result if I assume that the 1/100 really is 1/60 (adding one second to time each time the counter reaches 60 works).

    Pseudo code below, to make it more clear:

    Every 00"-01:
    > Add one to Counter

    Counter = 100
    >Add one to Seconds (Does not work. It takes over a second for Counter to reach 100)
    >Set Counter to 0

    However this works:

    Every 00"-01:
    > Add one to Counter

    Counter = 60
    >Add one to Seconds
    >Set Counter to 0

    The question is why MMF2 lists the time as 1/100, when it really is 1/60 (if we assume that the number is counting seconds, and not something else). A wild guess is that the 1/100 is somehow bound to the frame rate, rather than actual time, and if that's the case I don't see how I can keep track of 1/100:s of a second (not really neccessary, but would be nice :P).

    Thanks in advance for any answers.

  • I had no idea the every 1/100 was not always 1/100th of a second but I've just tested it and you're right. You are right about it relating to the frame rate as well; if the frame rate is n where n < 100 frames per second then the "Every 1/100" event will only occur n times per second. If n>= 100 frames per second then the "Every 1/100" event will occur 100 times per second as expected.

    Try replacing the first event with:

    - Every 00"-02 -> Add two to counter

    This should work as long as the frame rate is >= 50 frames per second.

    Edited 4 times, last by CoffeeCup (August 10, 2013 at 6:34 PM).

  • Thanks! That did work, and it actually makes sense that it works, although it's not very intuitive. The problem seems to be that MMF2 can't do things faster than 1/60:th of a second. Even though you can set the frame rate higher than 60, the game loop seems to be capped at 60. I tried setting the frame rate to 100, but that produced the same result as when it was 60.

    The question now is if I should have 1/100:th of a second, that increases by 2 per loop (which people are used to), or 1/60:th of a second that increases by 1 per loop (resulting in slightly better precision). I'll likely go with 1:100:ths, since that's less weird :)

  • Interesting post, I will use certainly later, thanks all ;)

    Hey I'm French, Hi!

    MMF2 SoundScape Engine (Moteur d'environnement) :
    FR: Please login to see this link.
    EN: Please login to see this link.

    May the .NET be with you (Star Wars .NET©)

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!