Jump to content
  • Advertisement
Sign in to follow this  
deavik

Demo - frame rate independent movement

This topic is 4682 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

Hello! I posted a demo of a work in progress a few days ago, and people complained about frame rate dependent movement. So I have tried to implement frame rate independent movement. It's a car racing game, arrow keys to move around. Click here and choose the "only binary" option (it's a windows zip file). The project archive file is not up to date. Please report any fluctuations in frame rates or any thing you find suspicious, thanks! Edit: Updated executable [Edited by - deavik on August 27, 2005 10:26:47 PM]

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
Sorry, it doesn't seem to work for me on my laptop...

Config :
Pentium 4 @ 3.06 GHz
DDR-SDRAM : 512 Mb
Graphics card : ATI Mobility Radeon 9700 64 Mb with updated drivers ;)
Windows XP Pro


It hangs at the very beginning of the program... The first time, I had the scene with your car displayed....It hanged. I CTRL-ALT-DELeted the program, and then, when I retry to run it, all what I've got is a black windows.....CTRL-ALT-DEL... :(

Share this post


Link to post
Share on other sites
Ohmygod, that's an inauspicious start! I have personally have computer configurations more ancient than Anon's but it's atleast running for me. Anyway, whoever you are, thanks for the feedback, and sorry my program caused your computer to hang.

Oh no! I just ran it myself and got the black screen! But minimizing and then un-minimizing it again got it working. I wonder what is going on ... Any other testers?

Share this post


Link to post
Share on other sites
Same problem. I get the black screen and then if I minimize and restore it comes on. However I get less than 1 fps.

Celeron 1.7ghz
512mb RAM
Gforce FX 5200 128mb

Share this post


Link to post
Share on other sites
Works fine for me!
~50fps on 533mhz celeron, ATI RAGE 128 PRO 16MB,320mb RAM(yes, it's time for upgrade, i know)

Share this post


Link to post
Share on other sites
OK, the last 2 reports by jnz86 and subflood saved my life - the black screen thing was making me looking like a right little chump.

Seriously, what I am doing to control frame rates is this:


#define FPS_FIXED 70 // or anything else

while (!done)
{
if (fps != 0)
getting_time_one_frame = 1000/fps;

if (fps >= FPS_FIXED)
{
to_delay = (int) (expected_time_one_frame - getting_time_one_frame);
SDL_Delay(to_delay);

game_logic();

} else // fps < FPS_FIXED
{
times_to_loop = (int)(getting_time_one_frame/expected_time_one_frame);

for (int i=0; i < times_to_loop; i++)
{
game_logic();
}
}

draw();

this_time_delay += to_delay;
count++;
fps_dt = SDL_GetTicks();

if ((fps_dt - fps_timer) > 500) //update after 500ms
{
fps = (int)count*1000/(fps_dt - fps_timer - this_time_delay);
sprintf(buf, "%d", fps); // the fps you see on the screen
fps_timer = fps_dt;
count = 0;
this_time_delay = 0;
}
SDL_GL_SwapBuffers();
}



Is some weird value being passed to SDL_Delay, that is causing this? And please, if you want, comment on my frame-rate-controlling method. This is the best I have come up with for the moment.

Share this post


Link to post
Share on other sites
Are you using ints or floats to hold and increment your time values? Try using floats, the rounding errors may be running down to 0 on some faster systems causing them to run slow. I have had that happen to me before and it was very frustrating to track down.

Share this post


Link to post
Share on other sites
evillive, I tried out your suggestion. Now it looks like its running fine except when the fps is way bigger than the fixed frame rate (70 fps). Could you please try this out for me?

Just the executable. Other files are in the zip file

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!