PDA

View Full Version : Timer



seiferalmasy
23-01-2008, 04:11 AM
Asphyre timer. Quick question. What exactly is onprocess? And what is "speed" for opposed to maxfps?

If I want agame to run at 100 fps with minimal cpu, what should I set to?

wodzu
24-01-2008, 12:33 PM
Asphyre timer. Quick question. What exactly is onprocess? And what is "speed" for opposed to maxfps?

If I want agame to run at 100 fps with minimal cpu, what should I set to?


MaxFPS sets the upper bound for rendering speed. Sometimes it is not necessary to render your scene with 100000 FPS ;) so you may drop it to the value assigned to MaxFPS.

Speed is the frequency of OnProcess calling. So if you set up Speed = 100 than it should be called 100 times per second.

If you want to run your game with 100 FPS then set up MaxFPS = 100.

You may do the rendering of your scene in OnProcess event but I would not advice that.

Personaly, I am doing in the OnProcess other not-so-important things. For example, keyboard handling in some static strategy game. 30 times per second is enough and it could save you some FPS if you do the handling in the OnProcess rather than in OnTimer.

seiferalmasy
24-01-2008, 08:43 PM
You see that is what I thought....

But guess what....when I place a little test in there like c:=c+1;

Nothing is added up. Nothing is being done in "onprocess" (speed set to say 60)

why is that?

LP
25-01-2008, 03:52 AM
But guess what....when I place a little test in there like c:=c+1;

Nothing is added up. Nothing is being done in "onprocess" (speed set to say 60)

why is that?
You need to call Timer.Process() in your OnTimer event.

seiferalmasy
25-01-2008, 11:56 AM
ah :oops:

cheers;)

masonwheeler
26-02-2008, 08:48 PM
Which version are you using, BTW? The Asphyre 3.1 timer doesn't implement max FPS correctly. Not sure if this has been fixed in later versions or not. If you want to get an accurate frame count, check the Latency property each frame and divide 1000 by that number. You'll want to average it out over several frames, though, as latency of individual frames can vary wildly due to thread scheduling, but overall speed remains pretty consistent.

(It was driving me crazy! I was trying to make an image move on-screen, and it was moving much too fast. Finally I wrote a routine to call outputDebugString every frame with a readout from the system clock, starting from a certain keypress and going until one second had passed. I consistently got 47 responses, even though the timer said it was running at 32 FPS.)