I have read almost every post on timing and have tried lots of different solutions with no luck.
My problem I am done with my breakout clone and have been testing it out.
I don't lock my frames rate because I end up having to move the ball too many pixels on slow machines, to have good game speed which ends up looking choppy.
So I use the method of finding TimeDelta and using that along with velocity to update the speed.
The problem I am having is that the speed changes on different machines.
Another thing is that for it to be payable not to fast on my machine I end putting the velocity at 1 or .4 etc
Here is where I get Timedelta which I call LastFrameTime
FrameTime = timeGetTime();
LastFrameTime = timeGetTime();
while(Msg.message!=WM_QUIT && g_mES.isEmpty()==FALSE)
{
FrameTime = (float)timeGetTime();
if(PeekMessage(&Msg,NULL,0,0,PM_REMOVE)) {
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}else {
g_mES.Process(); //process top engine
}
LastFrameTime =(float) timeGetTime() - FrameTime;
}
Any problems with that?
Here is how I update the paddle
pad->loc.x = (float) pad->loc.x -(1 * (LastFrameTime * 1.0f));
The only time my ball's x and y velocitys change speed is when they hit the paddle other wise they just get flipped if they hit somthing, so I use time delta only here and not every time the ball moves
balls[i]->X_velocity= balls[i]->velocity * (cos(balls[0]->angle)* (LastFrameTime * 1.0f)); //change x's and y's velocity
balls[i]->Y_velocity= balls[i]->velocity * (sin(balls[0]->angle)* (LastFrameTime * 1.0f));
balls[i]->loc.x =(float) balls[i]->loc.x + balls[i]->X_velocity; //update the balls location
balls[i]->loc.y =(float) balls[i]->loc.y + balls[i]->Y_velocity; //and return
Sorry for the long post but I wanted to make sure there was enough info, I am pulling what hair I have left out.
thanks for your help
-Marc
[edited by - dapeos on April 22, 2004 5:51:08 AM]