The Daily Click ::. Forums ::. Klik Coding Help ::. How do you make a custom timer?
 

Post Reply  Post Oekaki 
 

Posted By Message

JetpackLover



Registered
  01/03/2007
Points
  212
20th June, 2009 at 18:35:21 -

One that looks like this 00:00:00 minutes/seconds/milliseconds

and how would I make it count up?

I honestly have no clue...please help

 
http://www.invincibletime.com/

Devlog for HD MMF Game Omulus. Check it out because it's gonna be awesome. http://omulus.tumblr.com/

Follow me on the twitters https://twitter.com/JetpackLover


Muz



Registered
  14/02/2002
Points
  6499

VIP MemberI'm on a BoatI am an April FoolHonored Admin Alumnus
20th June, 2009 at 18:42:17 -

Create counter 1, counter 2, counter 3.
Counter 1 = minutes
Counter 2 = seconds

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.

Image

JetpackLover



Registered
  01/03/2007
Points
  212
20th June, 2009 at 18:58:10 -

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?

 
http://www.invincibletime.com/

Devlog for HD MMF Game Omulus. Check it out because it's gonna be awesome. http://omulus.tumblr.com/

Follow me on the twitters https://twitter.com/JetpackLover


Silveraura

God's God

Registered
  08/08/2002
Points
  6747

Game of the Week WinnerKlikCast StarAlien In Training!VIP Member360 OwnerWii OwnerSonic SpeedThe Cake is a LieComputerChristmas Tree!
I am an April Fool
20th June, 2009 at 19:06:31 -

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.

 
http://www.facebook.com/truediamondgame

JetpackLover



Registered
  01/03/2007
Points
  212
20th June, 2009 at 19:07:29 -

Forgive me if I sound dumb but what do you mean?

 
http://www.invincibletime.com/

Devlog for HD MMF Game Omulus. Check it out because it's gonna be awesome. http://omulus.tumblr.com/

Follow me on the twitters https://twitter.com/JetpackLover


OMC

What a goofball

Registered
  21/05/2007
Points
  3516

KlikCast Musician! Guy with a HatSomewhat CrazyARGH SignLikes TDCHas Donated, Thank You!Retired Admin
20th June, 2009 at 19:20:15 -

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.

Edited by OMC

 

  		
  		

JetpackLover



Registered
  01/03/2007
Points
  212
20th June, 2009 at 19:38:54 -

So has anyone made an accurate timer?

 
http://www.invincibletime.com/

Devlog for HD MMF Game Omulus. Check it out because it's gonna be awesome. http://omulus.tumblr.com/

Follow me on the twitters https://twitter.com/JetpackLover


Spitznagl

Cabinetmaker

Registered
  06/12/2008
Points
  4260

The SpinsterVIP MemberHas Donated, Thank You!Picture Me This Round 29 Winner!Picture Me This Round 31 Winner!Picture Me This Round 36 Winner!
20th June, 2009 at 21:28:38 -


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?



He was probably using the modulus operator. This way, you only need one value.
Here's a simple example:
http://www.mediafire.com/download.php?gnitnhnyznm

It seems to lose not even half a second every hour, and my watch could too fast.

 
...

Hernan



Registered
  04/03/2003
Points
  707

VIP Member
20th June, 2009 at 21:42:25 -

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.

 
This space is for rent

Spitznagl

Cabinetmaker

Registered
  06/12/2008
Points
  4260

The SpinsterVIP MemberHas Donated, Thank You!Picture Me This Round 29 Winner!Picture Me This Round 31 Winner!Picture Me This Round 36 Winner!
20th June, 2009 at 22:09:55 -

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.

 
...

Hernan



Registered
  04/03/2003
Points
  707

VIP Member
20th June, 2009 at 22:50:01 -

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

Edited by Hernan

 
This space is for rent

Spitznagl

Cabinetmaker

Registered
  06/12/2008
Points
  4260

The SpinsterVIP MemberHas Donated, Thank You!Picture Me This Round 29 Winner!Picture Me This Round 31 Winner!Picture Me This Round 36 Winner!
20th June, 2009 at 23:38:34 -

You are right! Thanks

 
...

Muz



Registered
  14/02/2002
Points
  6499

VIP MemberI'm on a BoatI am an April FoolHonored Admin Alumnus
21st June, 2009 at 02:08:55 -

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.

Image

Cecilectomy

noPE

Registered
  19/03/2005
Points
  305

Has Donated, Thank You!VIP MemberWeekly Picture Me This Winner!Cardboard BoxGhostbuster!Pokemon Ball!ComputerBox RedSanta HatSnowman
I am an April Fool
21st June, 2009 at 03:22:25 -

use my widget.

http://supertacogames.com/index.php?page=Download%20Details&id=8

this question has been asked quite a bit lately. hmmm.

Edited by Cecilectomy

 
n/a

Assault Andy

Administrator
I make other people create vaporware

Registered
  29/07/2002
Points
  5686

Game of the Week WinnerVIP Member360 OwnerGOTM JUNE - 2009 - WINNER!GOTM FEB - 2010 - WINNER!	I donated an open source project
21st June, 2009 at 09:23:36 -

Use the TimeX extension? I'm pretty sure that's independent of MMF's loops, but someone should verify that.

 
Creator of Faerie Solitaire:
http://www.create-games.com/download.asp?id=7792
Also creator of ZDay20 and Dungeon Dash.
http://www.Jigxor.com
http://twitter.com/JigxorAndy
   

Post Reply



 



Advertisement

Worth A Click