frame timer code
what is a good way to base frame movement off a constant interval? for example, if i just put
frameMove()
{
// some rotation code
something.rotate
}
the rotation speed depends on the frame rate.. what would be a good way to base it off a constant time interval?
-b
Frame rates will rarely give you a constant interval. I can only advise an alternate method.
Keep track of the difference in time between frames and make your your rotation time dependent and frame independent.
e.g.
frameMove()
{
deltaTime = currentTime - timeOnLastFrame;
// This uses seconds as an example though it
// may be easier to work with milliseconds
rotation = radsPerSecond * deltaTime;
timeOnLastFrame = currentTime;
}
This is a very simple example you''ll need to modify it to suit your needs.
Chris Z.
ZeroFX Interactive
Keep track of the difference in time between frames and make your your rotation time dependent and frame independent.
e.g.
frameMove()
{
deltaTime = currentTime - timeOnLastFrame;
// This uses seconds as an example though it
// may be easier to work with milliseconds
rotation = radsPerSecond * deltaTime;
timeOnLastFrame = currentTime;
}
This is a very simple example you''ll need to modify it to suit your needs.
Chris Z.
ZeroFX Interactive
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement