Archived

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

owl

Ok, Limiting Frame Rate

Recommended Posts

This comes from here What do you know about "time-based movement"? How this method should be implemented in a game? Is it really better than limiting framerate? I ask because I don''t know

Share this post


Link to post
Share on other sites
quote:
Original post by Anonymous Poster
-


I notice you bumped, are there any questions you need answered in relation to the article or in general?

Share this post


Link to post
Share on other sites
I read the article, and the conclusion makes me wonder if someone has a better technique...

"In conclusion, I cannot say if this is the absolute best way to handle character movement, but it’s a method that has worked for me thus far."

Limiting frame rate worked fine to me, but I see people doesn''t like it, so, I would like to read more opinions about time-based movement. Is this a common technique in game programming?

Share this post


Link to post
Share on other sites
Very common, AFAIK, and recommended by many.

Imagine spending big bucks on the latest top-end graphics card, a load of memory, and the fastest processor on the market. Then you buy a game and expect to get the highest frame rate possible. But, the programmer decided to limit the framerate to 30 fps. Personally, I wouldn''t mind as I would just enjoy the nifty eye candy my card allows. However, if you browse through game-related forums around the net, many hardcore gamers judge games by frame rate (as well as eye candy), and even great gameplay will lose out sometimes. Unfortunate but true.

Using time based movement allows frame rate to scale to the machine the game is run on, while maintaining a consistant animaton speed. This way, those who have the hardware can get their money''s worth (as they see it) and those who don''t can still enjoy the game. Myself, I *do* believe time based animation is a better method than frame rate limitation.

Out of curiosity, what gives you the opinion that people don''t like time-based animation?

Share this post


Link to post
Share on other sites
quote:

Out of curiosity, what gives you the opinion that people don''t like time-based animation?



No no. People don''t like "frame rate limitation" This is why I want to learn the best possible time-based animation technique, and wanted to read programmers opinion. Thank you for your post.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
If you use time based animation, you could set a coefficient that could slow down/speed up the engine. Add a camera that pans(scripts) when the engine is slowed down and you have bullet time.

Share this post


Link to post
Share on other sites
Hi

The other problem with limiting frame rate is that although the animation runs at a constant speed when you are running AT that capped frame rate, you will still have a problem when the frame rate falls lower than that frame rate. So unless you set the maximum frame rate to 5 fps or something, some computers will run the animations slower than others.

Share this post


Link to post
Share on other sites
Just as Poya says, if you only have frame-rate limitations then the game will run slower if the fps is lower than your limit. This might not be a problem at certain times, but mostly it will. Specially if you are making a multiplayer game, then this will cause the player to fall out of sync (unless the server does *ALL* the calculations for all the clients).

regards,
/Omid

Share this post


Link to post
Share on other sites
I could see the use for limiting the framerate.

Typically a game or 3D application with constant animation uses either a continuous loop or grabs the idlehandler and returns false in it so that it loops all the time.

Even if you use D3DSWAPEFFECT_COPY_VSYNC your game still runs at 100% CPU. What I am wondering about, if your game runs at 400 fps, and you use COPY_VSYNC so that it runs at 60 fps, it still uses 100% CPU. Apparently Present() uses a tight loop to check vsync.

If you have a simple animation that runs at 400 fps in windowed mode, it makes sense to limit the framerate with small sleeps just to cool off the CPU.

Share this post


Link to post
Share on other sites
Could any of you add time-based movement to this little c++ example? Just to see how many different aproaches are out there.
    
#define FPS 60
#define MAXFPSTIME 1000/FPS

DWORD dwLastTime,dwCurrentTime;
int x=0;
int y=0;

int main()
{
while((x<640)&&(y<480))
{
x++;
y++;

dwCurrentTime = GetTime(); //(or tick whateva)

if (dwCurrentTime-dwLastTime) > MAXFPSTIME)
{
DrawStuff();
}
dwLastTime=dwCurrentTime;
}
return 0;
}


[edited by - xaxa on September 3, 2002 7:57:03 PM]

Share this post


Link to post
Share on other sites
Strange... I've got a fullscreen Direct3D app that only uses 10% of my CPU at any given time (It's only rendering a couple hundred polys though... no framerate limiter of my own... just the 60Hz present sleep... No Sleep() of my own)

Using the typical "game" loop:

for( ; ; )
{
if (PeekMessage)
{
...
}
else
{
Render, etc.
}
}

[edited by - Nypyren on September 4, 2002 10:50:56 PM]

Share this post


Link to post
Share on other sites