• Advertisement

Archived

This topic is now archived and is closed to further replies.

DirectDraw Animation

This topic is 5789 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi... I''m trying to set up some simple animation with DirectDraw. I''ve tried frame-based (which, I think, sux) and with High-Peformance counter (QueryPerformanceCounter, Frequency)... My demo with high-perfomance is just blinking (the code is taking too much time to go through I think). You guys have any suggestions of the way I should use to do my timing? Or any demo that I can see? Last of The Returners

Share this post


Link to post
Share on other sites
Advertisement
I have always used GetTickCount() in my games, it is only accurate to within 10 ms but that has been accurate enough for everything I have done. Here is a brief example copied almost directly from a 2D asteroids game I did a few years ago.

int currentTime, previousTime = GetTickCount();
while(true) //main game loop
{
currentTime = GetTickCount();
float elapsedTime = (currentTime - previousTime)/1000.0f; //elapsed time in seconds

//update coordinates of ship based on time elapsed
//and ship''s velocity (in pixels per second)
ship.x += (ship.xVel * elapsedTime);
ship.y += (ship.yVel * elapsedTime);

previousTime = currentTime;
}

Share this post


Link to post
Share on other sites

  • Advertisement