# Ticking movement

## Recommended Posts

AriusMyst    130
Hey, I'm trying to get an accurate account of the time passed rendering each frame - so that I can scale my translations. I currently have, as a timer, this:
class pixieTimer
{
protected:
//---Vars----------------------------------------------------------------------------------------------------------
LARGE_INTEGER m_iFrequency;
LARGE_INTEGER m_iLastQuery;
LARGE_INTEGER m_iDelta;
public:
pixieTimer()
{
}

~pixieTimer()
{
}
//-----------------------------------------------------------------------------------------------------------------

void Init()
{
QueryPerformanceFrequency(&m_iFrequency);
Update();
}

void Update()
{
LARGE_INTEGER kTempTimer;
QueryPerformanceCounter(&kTempTimer);
}

double GetDeltaSeconds()
{
}

double GetDeltaMillis()
{
}

};


Then, if I run the code:
		static float index = 0;
index += 1 * (float)PD->GetDelta(); //PD->GetDelta() equates to pixieTimer->GetDeltaMillis()
D3DXMATRIX matRotateY;
D3DXMatrixRotationY(&matRotateY, index);
PD->GetDirectXDevice()->SetTransform(D3DTS_WORLD, &(matRotateY));


The result is not a steady rotation, rather the rotation appears static. I am updating the timer once every frame, just before BeginScene. I should mention that the mesh is rotated when it is first rendered( when, it should face entirely forward ), but it doesn't appear to rotate after that. I used this as a reference: http://www.gamedev.net/community/forums/topic.asp?topic_id=113457&whichpage=1򕌅 I did try before hand to do something with GetTickCount(), but after reading around it seems that this is the most appropriate way to do it. I just can't seem to get it to work correctly. Thanks.

##### Share on other sites
ViperG    206
if your only drawing 1 quad on the screen, your frame time might be so small it's truncating it when you cast it as a float, so it's not signficant enough to cause movement.

also why do you have index += 1 * (the 1 isn't doing anything)

also if you are trying to get a rotation amount, your setting index=0 every frame and just adding the time difference, your not actually increase the actual rotation of the object. You need to store the heading/rotation of the object and keep adding to it every frame, so make it a global or make a class etc.

only other thing I can recommend is write it to the screen, or artificially increase the amount (*100x fold, etc to make sure it does infact have a value already)