Hi again

OK I''ve been at this for days and still cant get anything working

this is driving me mad! hehe
Below is the code I am currently using to keep my movement/fps speed correct and uses the timing code from a gamedev article.
class framerate
{
public:
float targetfps;
float fps;
LARGE_INTEGER tickspersecond;
LARGE_INTEGER currentticks;
LARGE_INTEGER framedelay;
float speedfactor;
void Init(float tfps);
void SetSpeedFactor();
} framer;
float tticks;
float tseconds;
void framerate::Init(float tfps)
{
targetfps = tfps;
QueryPerformanceCounter(&framedelay);
QueryPerformanceFrequency(&tickspersecond);
//startticks = framedelay;
}
void framerate::SetSpeedFactor()
{
QueryPerformanceCounter(¤tticks);
//This frame''s length out of desired length
speedfactor = (float)(currentticks.QuadPart-framedelay.QuadPart)/((float)tickspersecond.QuadPart/targetfps);
fps = targetfps/speedfactor;
if (speedfactor <= 0)
speedfactor = 1;
framedelay = currentticks;
}
I init the timer with Init() at the start of the program and call SetSpeedFactor() each frame to set the game speed.
How can I modify/add to the above code so that I can also keep a timer of elapsed seconds in real seconds since the game started please?
It might be easier now you can see the code im using

Pleeease this is driving me mad and I cant do anything else until I fix this hehe

Thanks again for all help

Adam