Timers
Blitz3D Forums/Blitz3D Programming/Timers
| ||
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?) |
| ||
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. |
| ||
What is it you are trying to do Zach? Rhy :) |
| ||
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 |
| ||
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. |
| ||
blitz3D timers suck really bad and are bugged Can you post a small example that demonstrates this? |
| ||
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 |
| ||
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. |
| ||
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 |
| ||
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. |
| ||
using FPS/1000 is Only for blitzmax, blit3D timers are alot different |
| ||
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? |
| ||
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. |
| ||
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. |
| ||
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. |