Skip to main content
gamedev.net
🔒 Locked

DirectDraw Animation

Started by Tera Apr 17, 2002 at 3:39 PM 0 replies 250+ views
Original Post
Tera
Tera
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
Last of The Returners
GAG34
GAG34
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;
}

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.