• Advertisement
Sign in to follow this  

2D game timing problem!

This topic is 4507 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 there! Here is the problem, i'm writting 2d board game. Game requires smooth movements of any objects: balls, score up's etc... How i done it: UpdateTimer() UpdateInput() Update(fUpdateTime) // updates all movements and gamelogic. Engine calls this function 100 times per second Draw(fAccuracyTime) // calls each frame. Within draw, i'm taking previos x position and new x position and calculating the real x pos for current time. Like X = (Xnew - Xold)*fAccuracyTime + Xnew. So objects moving around the screen almost smooth. But, my old video card (Radeon 9600Pro) was replaced with Radeon X800. So now the FPS is about 800 - 1200. And game lost smooth movements. So, can someone help me with game timing and movements for 2d games? Some tuts or articles will be great for me! [Edited by - limpacp on October 24, 2005 5:18:15 AM]

Share this post


Link to post
Share on other sites
Advertisement
It's a complex solution for a simple problem.

Just do it as follow:

//Pseudo code

fDeltaT = CurrentTime - LastFrameTime ;
Object.X += Object.VeloX * fDeltaT ;

You'll have the object moves around with a constant distant each time unit regardless of how fast the target system is.

Share this post


Link to post
Share on other sites
I think, if i will use fDeltaTime, i can get some porbs in math calculations, such as acceleration etc. I think calling update with fixed times per second with interpolated draw is more effective for 2D games.
I've found what was wrong with my code. Just need to interpolate frame time according previos results.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement