Archived

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

Eric Poitras

Handling FPS in a 2D game

Recommended Posts

Just wanted to know what would be a good FPS (frames per second) for a 2D game. Should I cap the FPS or is there a better way to handle animations and graphics? Let me know what you guys think. All that is necessary for the triumph of evil is that good men do nothing. -Edmund Burke

Share this post


Link to post
Share on other sites
the answer is obvious: "as many as possible" :-)

The best advice is to move your objects and such at time intervals, not frame intervals. Otherwise, your game may not run as nice on your machine as mine, or you are unnecessarilly limiting the system if the game is on a higher end machine than yours.

Just let the screen refresh as soon as it gets done with the last one. Move your units based on the current time, not frame.

Share this post


Link to post
Share on other sites
ok I get it... So it''s best having a universal timer for the game and then run everything with time instead of with the frames, I should have known that but I''m a little rusty.

Share this post


Link to post
Share on other sites
it''s time-based movement, which gives you greater flexibility (bullet-time in Max Payne? simply reduce the time step you pass to the physics, particles, sounds, ...).

it''s a bit more work, you''ve got to have accurate timers in the game, and account for things like pausing, ect... Having a general timing handler in the game should take care of these transparently.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
A very good way, at least for 2D-games, is to separate the rendering FPS and logic FPS. I''d suggest to cap your rendering FPS to 72 (or to the refresh rate at maximum) and the logic FPS to whatever suits for your (10-30 is fine for many games). And nothing prevents you to use time-based tick/update with this method if you really need it for something.

Share this post


Link to post
Share on other sites
My way (not necessarilly the right way) is to make every object that needs an update, for any reason, a PollingObject. Each polling object has a

virtual bool Poll( int time );

Which it inhereits and it then does whatever it needs to do for that loop of time. So every frame i can do something like:

PollAllObjects() {
foreach PollingObject {
object->Poll( GetTimeInTicks() );
}
}

Share this post


Link to post
Share on other sites