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

Post Reply  Post Oekaki 
 

Posted By Message

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 09:33:21 -

my widget uses timeX object. im pretty sure its mmf independant. its as accurate as your computers clock.

 
n/a

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
21st June, 2009 at 09:35:45 -

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.

 
http://www.facebook.com/truediamondgame

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 09:41:34 -

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.

 
n/a

JetpackLover



Registered
  01/03/2007
Points
  212
21st June, 2009 at 19:25:53 -


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.)

 
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


Hernan



Registered
  04/03/2003
Points
  707

VIP Member
21st June, 2009 at 23:16:59 -


Originally Posted by DudeHuge

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.

 
This space is for rent

JetpackLover



Registered
  01/03/2007
Points
  212
22nd June, 2009 at 02:02:07 -

I've decided to use the widget it works brilliantly for what I want it for. Thanks for the enlightenment on all this stuff guys I appreciate it.

 
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
22nd June, 2009 at 06:04:47 -


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.

 
http://www.facebook.com/truediamondgame

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
22nd June, 2009 at 07:06:02 -

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.

 
n/a

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
22nd June, 2009 at 08:25:34 -


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.

 
http://www.facebook.com/truediamondgame

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
22nd June, 2009 at 08:46:09 -

what? external loops?

not when its based on difference in time. delta.

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.

http://ruby.about.com/od/gameprogramming/ss/gameprog4_5.htm

 
n/a
   

Post Reply



 



Advertisement

Worth A Click