i would recommend you use a method such as delta timing, this is a rather handy method for such when you have fast, slow computers etc.
What is it?
http://en.wikipedia.org/wiki/Delta_timing
i have written some code that does delta timing, if you want ill give it to you.
with delta timing its not a matter of the speed of the computer or frames but on time.
if one computer has like 60 fps and another had 30 fps they wouldn't move at the same rate. even if you had the 30fps go twice the speed.
FF_Timer.h
class CTimer
{
float timeAtGameStart;
// int timeAtGameStartMin;
//int timeAtGameStartSecond;
UINT64 ticksPerSecond;
float lastUpdate;
float fpsUpdateInterval;
unsigned int numFrames;
float fps;
float lastGameTime;
float position;
float velocity;
float acceleration;
//public
public:
void InitGameTime();
float GetGameTime();
void UpdateFPS();
float GetDeltaTime();
float GetTimerPos(float dt,float MoveSpeed);
float GetFPS() {return fps;}
};
FF_Timer.cpp
//functions
#include <global header or something here>
void CTimer::InitGameTime()
{
// We need to know how often the clock is updated
if( !QueryPerformanceFrequency((LARGE_INTEGER *)&ticksPerSecond) )
{ticksPerSecond = 1000;}
// If timeAtGameStart is 0 then we get the time since
// the start of the computer when we call GetGameTime()
timeAtGameStart = 0;
timeAtGameStart = GetGameTime();
lastUpdate = 0;
fpsUpdateInterval = 0.2f; //Updating time for FPS
numFrames = 0;
fps = 0;
lastGameTime = GetGameTime();
position = 0;
velocity = 1;
acceleration = 0.1f;
}
float CTimer::GetGameTime()
{
UINT64 ticks;
float time;
// This is the number of clock ticks since start
if( !QueryPerformanceCounter((LARGE_INTEGER *)&ticks) )
{ticks = (UINT64)timeGetTime();}
// Divide by frequency to get the time in seconds
time = (float)(__int64)ticks/(float)(__int64)ticksPerSecond;
// Subtract the time at game start to get
// the time since the game started
time -= timeAtGameStart;
return time;
}
void CTimer::UpdateFPS()
{
numFrames++;
float currentUpdate = GetGameTime();
if( currentUpdate - lastUpdate > fpsUpdateInterval )
{
fps = numFrames / (currentUpdate - lastUpdate);
lastUpdate = currentUpdate;
numFrames = 0;
}
}
float CTimer::GetDeltaTime()
{
float dt = GetGameTime() - lastGameTime;
// Increment with dt instead of calling
// GetGameTime() to avoid loosing time
lastGameTime += dt;
return dt;
}
[ FF - Engine ] - Coming Soon...