Original Post
I want to use a timer to calculate how many degrees each step an object should rotate in order to take 5 seconds for a 180 degree rotation like this:
DWORD start;
DWORD elapsed;
(data-type) propyaw;
double yaw;
while (game running)
if (player starts rotating) // run only when key is pressed
start = GetTickCount();
if (player rotating) // run while key is down
elapsed = GetTickCount() - start;
propyaw = (elapsed / 5000) * 180;
yaw = propyaw.
yaw is then passed into a rotation matrix. You would obviously check to see when yaw is greater than 360 and then handle that when it happens.
My question is what data types I should be using during the yaw calculation and whether or not I should be using any type-casts.
As far as I know DWORD are integers so GetTickCount() - start should not be a problem.
Elapsed / 5000 will probably be a float won't it? or will the conversion from DWORD to float work at all? figure * 180 will probably be a float if it works. Then I have to make yaw a double for use with sin and cos don't I?
I know I have a limited knowledge of data types and what to use when etc.. but I have been able to get by until now. This code will just not work no matter what types I put where and believe me I have tried about 20 different combinations.
Any help appreciated,
Paulcoz.
Edited by - paulcoz on 3/21/00 1:14:15 AM