fast frames

Started by
2 comments, last by meeshoo 12 years, 2 months ago
So, I have a game that runs at over 100 frames/sec:



Should I just let it run really fast like that? Or should I limit the rate to 60 or 70 frames a second?
Advertisement
Everything that needs to be should be frame independent. You can do this by multiplying by delta time (i.e. the time elapsed between each frame)


float deltaTime = gameTime.GetElapsedTime( ); // elapsed time since last loop iteration in milliseconds/seconds or thereabouts.. I generally prefer it in 100ths of a second, i.e. ms * 100.0f
//..
player.position.x += player.velocity.x * deltaTime;
player.position.y += player.velocity.y * deltaTime;
//..
frame += frameSpeed * deltaTime;


you get the point, sorry i don't know the correct terminology for what exactly I'm showing you, maybe someone else can better explain.
you have two options:
1. use a timer to lock your game to x frames every second(with methods ensuring critical input isn't loss).
2. use a time-step(per above posts), to lock your input every frame to only increment by a specefic amount, regardless of how your fps jumps/drops.

here's a good article on the subject of time-steps: http://gafferongames.com/game-physics/fix-your-timestep/.
Check out https://www.facebook.com/LiquidGames for some great games made by me on the Playstation Mobile market.
You got to do it frame independent as a general rule, because if you set it for 60 fps for example, it might run with 50 fps on some older machines(well, not this game I guess, but as a general rule), so you want to gather your input at fixed time steps.

This topic is closed to new replies.

Advertisement