The Daily Click ::. Forums ::. Klik Coding Help ::. Alternatives to the timer
 

Post Reply  Post Oekaki 
 

Posted By Message

Ando



Registered
  08/04/2006
Points
  100
19th September, 2008 at 20:56:42 -

So if using "Every 1/100 seconds" and other such events is just totally stupid and wrong and stuff (and I can see why - varying computer speeds can have a great effect on this), what exactly am I supposed to use as an alternative? Like if I wanted an event to occur every second or something, how would I do that?

 
n/a

Don Luciano

Heavy combat pancake

Registered
  25/10/2006
Points
  380

VIP Member
19th September, 2008 at 21:06:15 -

Well keep the framerate always the same, and seconds should work properly.

 
Code me a sausage!

Codemonkey

Always Serious

Registered
  06/11/2007
Points
  164

Code MonkeyKlikCast StarVIP MemberAttention GetterWii Owner360 OwnerThe Cake is a LieCardboard BoxHero of TimeI'm a Storm Trooper
I'm on a BoatIt's-a me, Mario!PS3 OwnerSonic SpeedGOTM - SEPTEMBER 2009 - WINNER!Evil klikerPokemon Ball!I am an April Fool
19th September, 2008 at 21:07:28 -

Yeah, just do that!

 
You can log off any time you like, but you can't ever leave.

Pixelthief

Dedicated klik scientist

Registered
  02/01/2002
Points
  3419

Game of the Week WinnerWeekly Picture Me This Winner!You've Been Circy'd!VIP MemberI like Aliens!Evil klikerThe SpinsterI donated an open source project
19th September, 2008 at 21:12:16 -

MMF doesn't count in seconds, it counts in frames. Executing the "Always" event will make an action occur every frame of gameplay, which is normally 50 times per second. When the game lags a little, this might be less than 50, but will never be more. Meanwhile the timer events, like "Every 1.00 seconds" will execute in their REAL-TIME values. So when the game is running at 50 FPS, this is like having the event run every 50th frame, like 50, 100, 150, etc. But if the game slows down incredibly, like 2 FPS, it will run every other frame. At 1 FPS, it will execute on every frame.


If you want to keep track of time in relation to how the game-world sees it, use a counter. Have an events: "Always: add 1 to value". Then, from the start of the game, divide this by 50 to see the amount of "in-game seconds" that have elapsed. Divide it by 3000 for "in-game minutes", etc.

 
Gridquest V2.00 is out!!
http://www.create-games.com/download.asp?id=7456

AndyUK

Mascot Maniac

Registered
  01/08/2002
Points
  14586

Game of the Week WinnerSecond GOTW AwardHas Donated, Thank You!VIP Member
19th September, 2008 at 23:17:20 -

The reason 'every whatever seconds' is not a good idea for some things is because it doesn't sync up with MMF.

So if you make a character start shooting bullets 'every second', but only when you're pressing the space bar, when does the first bullet get shot?
you wont always be pressing the space bar dead on 1 seconds, it could be just after a second or half way though. So it's actually inconsistent in that respect.

Image Edited by the Author.

 
.

-MacAdaM-

Megaman Fosho

Registered
  12/02/2008
Points
  560
20th September, 2008 at 03:44:36 -

Isnt there an option like...
Always

Set counter 1 to seconds


 
Your just jealous that you're not as awesome as me.
(And my megaman avatar )

Bibin

At least 9001

Registered
  01/07/2005
Points
  308

Silver Cup WinnerGOTW Winner!Has Donated, Thank You!VIP Member
20th September, 2008 at 04:16:56 -

I don't get why we use 50hz. Computer monitors usually are at at least 60hz, even in non-ntsc areas - computer monitors use neither NTSC or PAL, so I don't get why anyone would run their monitor at such an eye-burning refresh rate.

 
n/a

Pixelthief

Dedicated klik scientist

Registered
  02/01/2002
Points
  3419

Game of the Week WinnerWeekly Picture Me This Winner!You've Been Circy'd!VIP MemberI like Aliens!Evil klikerThe SpinsterI donated an open source project
20th September, 2008 at 04:29:40 -

you can just use an "always: add 1 to counter" to find the time in frames since start of level

 
Gridquest V2.00 is out!!
http://www.create-games.com/download.asp?id=7456

Phredreeke

Don't listen to this idiot

Registered
  03/08/2002
Points
  4504

You've Been Circy'd!VIP MemberPS3 Owner
20th September, 2008 at 15:00:56 -


Originally Posted by Moffitt (bibin)
I don't get why we use 50hz. Computer monitors usually are at at least 60hz, even in non-ntsc areas - computer monitors use neither NTSC or PAL, so I don't get why anyone would run their monitor at such an eye-burning refresh rate.



Probably cause 50 is a nice even number.

 
- Ok, you must admit that was the most creative cussing this site have ever seen -

Make some more box arts damnit!
http://create-games.com/forum_post.asp?id=285363

Eternal Man [EE]

Pitied the FOO

Registered
  18/01/2007
Points
  2955

Game of the Week WinnerHero of TimeLOL SignI am an April Fool
20th September, 2008 at 15:04:57 -


Originally Posted by Phredreeke

Originally Posted by Moffitt (bibin)
I don't get why we use 50hz. Computer monitors usually are at at least 60hz, even in non-ntsc areas - computer monitors use neither NTSC or PAL, so I don't get why anyone would run their monitor at such an eye-burning refresh rate.



Probably cause 50 is a nice even number.



Tell that to the clock!

 
Eternal Entertainment's Code'n'Art Man

E_E = All Indie


...actually Ell Endie, but whatever.
Image
Image

aphant



Registered
  18/05/2008
Points
  1242
20th September, 2008 at 15:11:41 -


Originally Posted by Phredreeke
Probably cause 50 is a nice even number.



So is 2.

 

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 September, 2008 at 03:09:26 -

Use custom timers based on event loops and not seconds:

Always add 1 to counter

If counter >= 10 then
* Shoot bullet
* Set counter to 0.

If you want the one counter for multiple conditions, instead of resetting it you can simply perform a mod function on it:

If counter mod 10 = 0 then
* Shoot bullet

 
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

Muz



Registered
  14/02/2002
Points
  6499

VIP MemberI'm on a BoatI am an April FoolHonored Admin Alumnus
21st September, 2008 at 07:32:10 -

Uh, the MMF timer is very bad, because MMF was built on top of a frame rate system, rather than on top of the timer. I'm planning to make all my timed events counter based for my next MMF game - having a counter add up by 1 every 0.05 seconds and then my "every 1 second" events will wait till the counter reaches 20. Construct handles timers fine, but nobody likes it

Monitors run at 50/60 Hz because our power supply does. And the higher the frequency, the less eye-burning it does

 
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
   

Post Reply



 



Advertisement

Worth A Click