Timers

Blitz3D Forums/Blitz3D Programming/Timers

Zach3D(Posted 2005) [#1]
I'm not sure i understand timers,
From what i can guess
X = CreateTimer(60)
makes a timer that is set off every 60 frames. is that right?
Also how many frames are usually per second (50,60?)


xmlspy(Posted 2005) [#2]
Yep for the first question (I use it for that). The amount of frames per second depends on the amount of stuff you make your program do while on runtime. So, if it's a blank screen it is probably doing more than a thousand FPS, but once you draw stuff onto the screen it will lower that, as it's doing more.


Rhyolite(Posted 2005) [#3]
What is it you are trying to do Zach?

Rhy :)


Neochrome(Posted 2005) [#4]
timer is very usfull for making games work on the TV with no stuttering!
move PAL tvs work on 50hz, most NTSC work on 60hz


Zach3D(Posted 2005) [#5]
well i create a timer to try to make something happen after a certain amount of time, but blitz3D timers suck really bad and are bugged, so i just use my own idea.


big10p(Posted 2005) [#6]
blitz3D timers suck really bad and are bugged


Can you post a small example that demonstrates this?


John Blackledge(Posted 2005) [#7]
Here's a simple example:
Const FPS=30
Global framePeriod = 1000/FPS
frametimer = CreateTimer(framePeriod)
While Not Keyhit(1)
	UpdateWorld()
	RenderWorld()
	WaitTimer frametimer
	ProjectUpdate()
	Flip
Wend
End



tonyg(Posted 2005) [#8]
Is that right John?
Surely you stick the FPS in the CreateTimer command rather
than 1000/FPS.
If you specified 10 FPS you'd be putting 100 in the creatimer function but specify 60 FPS and you only put 16.


Banshee(Posted 2005) [#9]
move PAL tvs work on 50hz, most NTSC work on 60hz

Just to clarify, tv signals have two fields per frame so PAL runs at 25fps and NTSC runs at 30. The Human eye can distinguish up to around 50-60 frames per second (depending upon the individual) beyond which we can't perceive a difference, so aiming for 60fps is a good idea for game coders.

As for the framerate thing, I use this tutorial and it works just fine for me:
http://www.bansheestudios.com/stuff/timerBasedMovement.html


big10p(Posted 2005) [#10]
As tonyg says.

Example from the docs:
; Create the timer to track speed
frameTimer=CreateTimer(60)

; Your main screen draw loop
While Not KeyHit(1)
WaitTimer(frameTimer) ; Pause until the timer reaches 60
Cls
; Draw your screen stuff
Flip
Wend


You basically just plug the FPS (or any per-second amount) straight into CreateTimer(). I still don't see any problem.


Zach3D(Posted 2005) [#11]
using FPS/1000 is Only for blitzmax, blit3D timers are alot different


John Blackledge(Posted 2005) [#12]
Yes, but 60 what?

Mark Sibly says "This command will halt execution until the timer reaches its value. "
Blitz help code:
frameTimer=CreateTimer(60) 
; Your main screen draw loop 
While Not KeyHit(1) 
WaitTimer(frameTimer) ; Pause until the timer reaches 60 
Cls 
; Draw your screen stuff 
Flip 
Wend 

So I'm assuming that it's 60 millisecs, not 60 frames.
Otherwise who knows how long 60 frames would take?


Gabriel(Posted 2005) [#13]
So I'm assuming that it's 60 millisecs, not 60 frames.
Otherwise who knows how long 60 frames would take?


Eh? It's neither. It's 60 times per second. Or 16.6r millisecs.


John Blackledge(Posted 2005) [#14]
Sorry to keep questioning this, but Mark says "Pause until the timer reaches 60".

In other words it's a incrementing counter. When it reaches 60 the code moves on. I'm assuming that means =>60 millisecs from when the counter was last checked (last loop).

If possible, it would be good for Blitz Support to clarify this.


Gabriel(Posted 2005) [#15]
I doubt Mark wrote that. The docs are put together from work by a lot of people. The examples, in particular, are often from other people. The same docs page called the parameter frequency. So either way, the docs are wrong, because they contradict themselves.