Sign in to follow this  
limpacp

2D game timing problem!

Recommended Posts

limpacp    122
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
Skeleton_V@T    512
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
limpacp    122
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this