Every 1 second,
add 1 to counter 2.
When counter 2 = 60,
set counter 2 to 0
add 1 to counter 1.
Milliseconds are going to be a problem, though. I think MMF can only go as low as 0.02 seconds, and not accurately.
Disclaimer: Any sarcasm in my posts will not be mentioned as that would ruin the purpose. It is assumed that the reader is intelligent enough to tell the difference between what is sarcasm and what is not.
I'm not really a fan of using the built in timer movement
What I'm using now is Always> add 1 to counter
I was told by someone that there is a way to use counters and have them work like timers based on division or something. I can't remember how that is done though.
It was something like 1/100 equals minutes 1/1000 equals hours, something like that don't quote me on it though
Anyone know what I'm talking about?
Also I supposed it doesn't really matter if the milliseconds aren't dead on, but why can't MMF count them accurately?
It's designed to stay in sync with actual time, not it's own internal loop. That's why you need to make your own loop, which you really should be doing anyway.
MMF runs by loops, it goes through the conditions then does it again, and then again. I think it's once per .02 seconds or something. So if you added 1 to a counter every loop, it would be a funky number depending on the speed. (FPS, more or less)
If you use Always, that's what it will do. The timer is separate from the loops... I think.
Originally Posted by DudeHuge I was told by someone that there is a way to use counters and have them work like timers based on division or something. I can't remember how that is done though.
It was something like 1/100 equals minutes 1/1000 equals hours, something like that don't quote me on it though
Anyone know what I'm talking about?
If you have a counter that counts the milliseconds then:
milliseconds=counter mod 1000
seconds=(counter/1000) mod 60
minutes=(counter/60000) mod 60
hours=(counter/3600000) mod 24 (you don't need the mod 24, if you're not counting days)
etc.
For the seconds and higher, don't you also need to substract the lower value before you divide?
That or you put the formulas between int() to get rid of the decimals.
By default, MMF works in integers. So there's no need for placing int().
I'm not sure what you mean by "lower value" though.
Edit: I took a look at your example, and I see what you mean with "lower value" now. The answer is no, I do a different calculation than what you do. I calculate the total amount of seconds (by dividing the total milliseconds by 1000) and then remove the counts higher than 60 by taking mod 60.
What you do is different (it's all correct though, but seems much more complicated to me), you actually first get rid of all the minutes by taking mod 60000, then you get rid of the milliseconds by subtracting the mod 1000 and then finally divide by 1000 to convert the milliseconds to seconds. (actually you were working in centiseconds, but that all works the same)
You follow me?
Edit again: Sקɪтzпαɢʟ, I just realised that you are making things too hard for yourself Like I said, you actually subtract the milliseconds, but you don't need to do that! Dividing by 1000 is enough, because as I said earlier MMF works in integers by default. You don't need to get rid of the "lower value" at all! So if you remove the "-Global Value A mod 6000" part everywhere, you'll see that your timer will still work
Yeah, it's designed to run at the frame rate. One loop is run every 1/FrameRate seconds. So, if you have 50 FPS (default), it's 0.02 seconds per loop. You can't count faster than that without some sort of extension for it. And if your FPS drops, the built-in timer might skip over the 0.02 second count.
So, you can't count in milliseconds. You should be using a 'timer counter' like that for all your timer events anyway. I was thinking of writing an article about that some time but never got to it
Disclaimer: Any sarcasm in my posts will not be mentioned as that would ruin the purpose. It is assumed that the reader is intelligent enough to tell the difference between what is sarcasm and what is not.
The whole point of designing your own internal timer is to avoid being in sync with the computer clock. If you want to be in sync with the computer clock, just use the timer options in MMF2 itself. However if you're trying to create a game that depends on it's own internal values to keep track of everything, that's when you need an internal loop of your own.
brandon who said anything about being synced with the computers clock? when you start a timeX objects clock it keeps accurate time in milliseconds until you stop it. it still follows the rules of pausing when the app is minimized, being moved, or resized, unless you specify in the application settings. if you base it completely internally its going to end up being inaccurate to some degree. defeating the purpose of a clock in the first place.
Originally Posted by Hernan If you have a counter that counts the milliseconds then:
milliseconds=counter mod 1000
seconds=(counter/1000) mod 60
minutes=(counter/60000) mod 60
hours=(counter/3600000) mod 24 (you don't need the mod 24, if you're not counting days)
etc.
Hernan can I get an example of how this would work in MMF?(doesn't have to be an MFA.)
Originally Posted by Hernan If you have a counter that counts the milliseconds then:
milliseconds=counter mod 1000
seconds=(counter/1000) mod 60
minutes=(counter/60000) mod 60
hours=(counter/3600000) mod 24 (you don't need the mod 24, if you're not counting days)
etc.
Hernan can I get an example of how this would work in MMF?(doesn't have to be an MFA.)
Do I need to? It's dead easy ._. You only need to create 1 event!
Create 4 counters, let's call them 'counter', 'milliseconds', 'seconds', 'minutes'
Always
-Add 20 to 'counter'
(Yes I know, it won't be synced to real time etc etc. But let's assume DudeHuge doesn't need/want real time and has his game on 50fps)
-Set 'milliseconds' to value("counter") mod 1000
-Set 'seconds' to (value("counter")/1000) mod 60
-Set 'minutes' to (value("counter")/60000)
Alternatively, you can replace -Add 20 to 'counter' with -Set 'counter' to timer
if you do want it to be synced with real time.
Originally Posted by rand(0, $Cecil); brandon who said anything about being synced with the computers clock? when you start a timeX objects clock it keeps accurate time in milliseconds until you stop it. it still follows the rules of pausing when the app is minimized, being moved, or resized, unless you specify in the application settings. if you base it completely internally its going to end up being inaccurate to some degree. defeating the purpose of a clock in the first place.
When people say miliseconds or seconds, at least to me, it's automatically assumed that they're talking about accurate time, not internal game time. I mean if you you're talking about 1 second internal to the game, 1 second is going to be twice as long at 30fps then it is at 60fps, which could be both undesirable to some people and highly desirable to others. Few people ever consider this, which is the entire reason why I was trying to put it out there.
i see but its also desirable to have things in the game run at the same speed regardless of framerate. time based movements. thats why in most games when the frame rate drops you still move just as fast, just in fewer frames updated at longer intervals. i see where that can cause problems in mmf. i dont think the built in movements are timer based are they? and most custom movements dont use a time delta for movement.
i may update my widget to flag whether or not to use internal time based on framerate, or accurate external time. thanks brandon.
Originally Posted by rand(0, $Cecil); i see but its also desirable to have things in the game run at the same speed regardless of framerate. time based movements. thats why in most games when the frame rate drops you still move just as fast, just in fewer frames updated at longer intervals. i see where that can cause problems in mmf. i dont think the built in movements are timer based are they? and most custom movements dont use a time delta for movement.
i may update my widget to flag whether or not to use internal time based on framerate, or accurate external time. thanks brandon.
Actually, they achieve that by skipping frames, not by using external loops. It's actually highly undesirable to use external loops for in-game actions, especially movement based. If your game suddenly dips in framerate, you'll start getting a lot of varied results. For example, if you have a player that falls 1 pixel every 0.1 seconds and your game suddenly hitches up for a few seconds, he's going to be short cut his jump and that's going to cause a lot of frustration for the player. It's best to use internal loops and just turn on machine independent speed. That way your game still relies on it's internal loops, but skips rendering frames so as to keep the game from being slowed down by it's ability to render.
mmf loops 50 times a second. it it sudennly increases to 100 the total distance moved will be exactly the same. it will move according to the difference.
read this. im not sure im communicating what im actually thinking of well or you arent reading it well. this is what im talking about.