Hi,

It only gets called once per frame as do any OnUpdate and OnRender methods. The problem your having is because aElapsedTime does not represent the value that you're expecting. The TPGTimer class in PGE uses frame-based timing. If you call TPGTimer.Init(35.05, 2), this tells the timer that you want your simulation to run at 35 fps and to try and maintain this rate if the rate drops by two times. So then what does aElapsedTime represent? If the current frame is running at 17.5 fps, in order to keep the simulation running at 35 fps, aElapsedTime would be a value of 1.5 so when you multiply your object speed by aElapsedTime then it will speed the objects up to keep the overall simulation at 35 fps. If the frame rate go to 60+ fps then aElapsedTime would be around 0.5. It will continue to try to do this if the frame drops/increases by two frames.

The TPTimer class (PG.Timer) already has methods to help you with the timing your trying to do. You can use the TPTimer.FrameSpeed method. You use it like this:

[code=delphi]var
timer: Single;
...
timer := 0;
...
// return TRUE if 30 fps has elapsed
if PG.FrameSpeed(timer, 30.0) then
begin
...
end;
[/code]

The timer variable is used so that you track different timing speeds if needed. So, when doing your timing, keep in mind that aElapsedTime will return a value to represents a quantity that will keep objects in your simulation running at the specified desired simulation rate. By default TPTimer will set to 35 fps. This is a historical value that I've used the past 8+ years. In general I've found that optimal and silky smooth animation is better if your simulation rate is multiple of your monitors refresh rate. 60Hhz is a standard refresh rate for all monitors and it tends to be the default. So running at slightly above half this rate has proven to produce good results. You can of coarse change the simulation timing to what ever value you choose, but keep in mind the things I've outlined here.

So in this case your simulation is running a 35 fps. What you should do is this:

[code=delphi]var
FTimeCount: Single;
FSecs: Integer;
...
// update counter
FTimeCount := FTimeCount + (1.0 * aElapsedTime);

// check if a second has passed
if FTimeCount >= PG.Timer.GetDesiredFPS then
begin
FTimeCount := FTimeCount - PG.Timer.GetDesiredFPS;
Inc(FSecs);
end
[/code]